Skip to content

Instantly share code, notes, and snippets.

@C-Lodder
Created July 31, 2019 08:08
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 C-Lodder/a00cf98945d76c5a75a6f6fa2600a708 to your computer and use it in GitHub Desktop.
Save C-Lodder/a00cf98945d76c5a75a6f6fa2600a708 to your computer and use it in GitHub Desktop.
Lazy load JS
const scripts = [
'https://some-cdn.com/file.js',
'js/file1.min.js',
'js/file1.min.js',
];
scripts.forEach(file => {
const script = document.body.appendChild(document.createElement('script'));
script.async = false;
script.src = file;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment