Skip to content

Instantly share code, notes, and snippets.

@imitronov
Created October 24, 2017 08:27
Show Gist options
  • Save imitronov/0c2afd2af0636c05308a4aa03de018cb to your computer and use it in GitHub Desktop.
Save imitronov/0c2afd2af0636c05308a4aa03de018cb to your computer and use it in GitHub Desktop.
Отложенная загрузка
var scripts = new Array(
),
css = new Array(
'/assets/css/main.min.css'
);
function downloadJSAtOnload() {
var element;
for(var i = 0; i < scripts.length; i++){
element = document.createElement("script");
element.src = scripts[i];
element.type = 'text/javascript';
document.body.appendChild(element);
}
for(var i = 0; i < css.length; i++){
element = document.createElement("link");
element.href = css[i];
element.type = 'text/css';
element.rel = 'stylesheet';
document.body.appendChild(element);
}
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment