Set Viewport via JavaScript

Setup default viewport tag and apply an id to tag.

<meta id="viewportMeta" name="viewport" content="width=device-width, user-scalable=no">

Put this script above all external js files to run immediately.

<script type="text/javascript">  
    var vp = document.getElementById('viewportMeta');
    var setViewport = function() {
        if (screen.width < 768 ){
            vp.setAttribute('content', 'width=320, user-scalable=no');
        } else if (screen.width >= 768 && screen.width < 992){
            vp.setAttribute('content', 'width=768, user-scalable=no');
        } else {
            vp.setAttribute('content', 'width=device-width, user-scalable=no');
        }
    };

    window.onresize = function() {
        setViewport();
    };

    setViewport();
</script>  

Marco

daddy in love, runner, kiter, engineer, berlin, sheeeeeit!