Created
June 19, 2017 19:11
Star
You must be signed in to star a gist
Conditional meta viewport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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