I need to change the meta viewport tag, depending on the width of the visual viewport. I know HOW to do this, but it doesn’t work, I think, because the site works with this little JS too late for it to take effect. Perhaps this is not so, but this is my first thought.
In my application.js file:
$(document).ready(function() {
if (window.innerWidth <= 480) {
$('#viewport').attr('content', 'width=device-width');
}
}
In my index.html:
<meta id="viewport" name='viewport'>
Any ideas how I can get this unit to work as early as possible so that it really takes effect?
Thanks neil
source
share