Links
- stevesouders: Loading Scripts Without Blocking
- Dynamically loading an external JavaScript or CSS file
- Loading Javascript files in parallel
- SO: Load and execute order of scripts
- html5rocks: Deep dive into the murky waters of script loading
- The script defer attribute ✩ Mozilla Hacks
- tl;dr
- If the scripts don't care about order of loads, and you want max
parallelism, creating and adding script DOM nodes is the way to go
- You can get some ordering by having text content inside the script tag - that gets run only upon successful script load.
- If you want the order to be significant, then use
document.write
to write the script tags in head. They download in parallel but execute in order.
- If the scripts don't care about order of loads, and you want max
parallelism, creating and adding script DOM nodes is the way to go