Created
August 20, 2016 16:19
-
-
Save oleksapro/3b988f3757e2d6b039a787fc480228fb to your computer and use it in GitHub Desktop.
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
// http://learn.javascript.ru/external-script | |
function addScript(src){ | |
var script = document.createElement('script'); | |
script.src = src; | |
script.async = false; // чтобы гарантировать порядок | |
document.head.appendChild(script); | |
} | |
addScript('1.js'); // загружаться эти скрипты начнут сразу | |
addScript('2.js'); // выполнятся, как только загрузятся | |
addScript('3.js'); // но, гарантированно, в порядке 1 -> 2 -> 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment