Skip to content

Instantly share code, notes, and snippets.

@ArtemSites
Last active July 27, 2019 12:07
Show Gist options
  • Save ArtemSites/911f017d4498c6de940c76f1a5bbdb9c to your computer and use it in GitHub Desktop.
Save ArtemSites/911f017d4498c6de940c76f1a5bbdb9c to your computer and use it in GitHub Desktop.
Вставка дочернего файла js в родительский js файл.
//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