Created
April 26, 2017 01:11
-
-
Save benjaco/4a2e7616176466076b8a5a067d3092e8 to your computer and use it in GitHub Desktop.
lazyload js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadJs(url){ | |
return new Promise((resolve, reject)=>{ | |
var script = document.createElement('script'); | |
script.src = url; | |
script.onload = resolve | |
script.onerror = reject | |
document.head.appendChild(script); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment