Newest method to detect small screen

browser-feature-detection, css, javascript

Solution

You could use a polyfill such as https://github.com/paulirish/matchMedia.js/

Problem

While waiting for responsive design to find the way into a legacy web site, I would like to redirect a browser to a mobile version if the screen is smaller than 480px Hunting around I came up with ``` var isSmall = window.matchMedia ? window.matchMedia("screen and (max-width: 480px)") : screen.width<=480; ``` Question Is this acceptable in 2014 or is there a better/safer/newer method to do what I want without using useragent sniffing? References MDN Window.matchMedia JavaScriptKit CSS media query matching in JavaScript using window.matchMedia() QuirksMode screen.width is useless (hence the addition of matchMedia)

Original source