Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Created June 19, 2017 19:11
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save delphinpro/a962978d668b63e046889efd1073a67c to your computer and use it in GitHub Desktop.
Conditional meta viewport
/*
* Paste into the end <head>
*/
(function(){
var width = screen.width;
var oldViewport = document.querySelector('meta[name="viewport"]');
var viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
viewport.setAttribute('content', 'width=' + (width <= 640 ? '640' : 'device-width'));
document.head.replaceChild(viewport, oldViewport);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment