Last active
July 27, 2019 12:07
-
-
Save ArtemSites/911f017d4498c6de940c76f1a5bbdb9c to your computer and use it in GitHub Desktop.
Вставка дочернего файла js в родительский 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
//jqery method: | |
$.getScript('js/_child-script.js', function() {/*dependet code*/}); | |
//js method: | |
var _childScript = document.createElement('script'); | |
_childScript.src = '/js/_child-script.js'; | |
document.head.appendChild(_cart); | |
_childScript.onload = function() { | |
//The library is loaded but not yet initialized, | |
//its code has not yet been executed, | |
//so we plan to launch our code in the next tick (setTimeout()) | |
setTimeout(function() { | |
/*dependet code*/ | |
}, 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment