Using Media Queries in JavaScript using the window.matchMedia function. It is well supported and if you don’t need to support IE8 or lower you may use it without worry