Skip to content

Instantly share code, notes, and snippets.

@Victa
Created July 16, 2011 07:29
Show Gist options
  • Save Victa/1086106 to your computer and use it in GitHub Desktop.
Save Victa/1086106 to your computer and use it in GitHub Desktop.
Testing CSS media queries in JS
if (window.matchMedia('only screen and (max-device-width: 480px)').matches) {
// Asynchronously load iphone.js
} else if (window.matchMedia('only screen and (min-device-width: 481px) and ' +
'(max-device-width: 1024px) and ' +
'(orientation: portrait)').matches) {
// Asynchronously load ipad-portrait.js
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment