Auto scale a fixed-width html page with javascript

Auto scale a fixed-width html page with javascript

window.fixedwidth=1200;
document.body.style.overflowX='hidden';
window.debounce=function(fn,delay){var timer=null;return function(){var context=this;var args=arguments;clearTimeout(timer);timer=setTimeout(function(){fn.apply(context,args)},delay)}};
window.bodyscale=function(width){var devicewidth=document.documentElement.clientWidth;var scale=devicewidth/width;document.body.style.transformOrigin='0 0';document.body.style.transform='scale('+String(scale)+')';};
window.autoscale=window.debounce(function(){window.bodyscale(window.fixedwidth);setTimeout(function(){window.bodyscale(window.fixedwidth);},100);},100);
window.addEventListener('resize',window.autoscale);window.autoscale();

Change window.fixedwidth to your page's designed width, that's it.