You can dynamically add your scripts, so they load asynchronously by default.
To ensure orderly execution, you can explicitly mark them as non-synchronous.
Here is a minimal example:
<html> <head> <script> [ 'http://code.jquery.com/jquery-1.11.3.min.js', '1.js' ].forEach(function(src) { var script = document.createElement('script'); script.src = src; script.async = false; document.head.appendChild(script); }); </script> </head> <body> </body> </html>
1.js file contains jquery code:
$("body").append("<div>It works</div>");
In this example, files are downloaded asynchrounously, but retain the specified order. For further reading, you can see: http://www.html5rocks.com/en/tutorials/speed/script-loading/
source share