Running Your Code at the Right Time


#1
Run your code at the right time by making sense of DOMContentLoaded, load, async, defer, and position in the DOM!
This is a companion discussion topic for the original entry at http://www.kirupa.com/html5/running_your_code_at_the_right_time.htm

#2

This was an intelligent topic and although 2.5 years old is relevant today. How would you go about loading jQuery, bootstrap,js and waypoint.js (the latter 2 dependent on jQuery). Ideally I would want all three libraries to be loaded asynchrously, but prevent javascript execution until all 3 javascript libraries have been loaded?


#3

What you can use is: http://requirejs.org/

It is great because it was designed almost exclusively for this scenario. You can specify your jquery as the primary and then the rest as dependents :slight_smile:


#4

Thanks for getting back to me. I investigated requirejs.org and like others before me found it a little bulky for what I wanted it for. I ended up using load.js, but may use requirejs in the future.