Last active
December 23, 2015 04:09
-
-
Save gasolin/6578178 to your computer and use it in GitHub Desktop.
async download DOM and allow cross domain JS by Script DOM element
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
| var dom = document.createElement('script'); | |
| dom.src = "http://xxx/a.js"; | |
| document.head.appendChild(dom); |
Author
Author
sample from even faster web sites
Author
to ensure execute after load: script load method
`
var dom = document.createElement('script');
dom.src = "http://xxx/a.js";
dom.onloadDone = false;
dom.onload = function() {
dom.onloadDone = true;
init();
}
document.head.appendChild(dom);
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or
document.head.appendChild(dom);refer to shared/js/lazy_loader.js