Skip to content

Instantly share code, notes, and snippets.

@c7x43t
Last active September 1, 2021 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c7x43t/dc8441f1bcc6267c729356760892e4ed to your computer and use it in GitHub Desktop.
Save c7x43t/dc8441f1bcc6267c729356760892e4ed to your computer and use it in GitHub Desktop.
// Execute a function as soon as the website has loaded
// compatibility: ES3
function loadScript(script) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len;_key++) {
args[_key - 1] = arguments[_key];
}
if (document.readyState === "complete" || document.readyState === "interactive") {
script.apply(void 0, args);
} else {
document.addEventListener("DOMContentLoaded",script.bind.apply(script, [this].concat(args)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment