# Running Your Code at the Right Time

**URL:** https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075
**Category:** programming
**Created:** [November 21, 2014, 4:02am UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075 "2014-11-21T04:02:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [November 21, 2014, 4:02am UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/1 "2014-11-21T04:02:20Z")

</div>

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](http://www.kirupa.com/html5/running_your_code_at_the_right_time.htm)

---

<div class="post-metadata">

### Author: ![eggs](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@eggs](https://forum.kirupa.com/u/eggs)
#### Post date: [April 17, 2017, 11:39pm UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/2 "2017-04-17T23:39:26Z")

</div>

> **[Running Your Code at the Right Time](http://forum.kirupa.com/t/running-your-code-at-the-right-time/352075)**
>
> 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

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?

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [April 18, 2017, 5:55pm UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/3 "2017-04-18T17:55:15Z")

</div>

What you can use is: [http://requirejs.org/](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 🙂

---

<div class="post-metadata">

### Author: ![eggs](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@eggs](https://forum.kirupa.com/u/eggs)
#### Post date: [April 20, 2017, 7:50am UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/4 "2017-04-20T07:50:19Z")

</div>

Thanks for getting back to me. I investigated [requirejs.org](http://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.

---

<div class="post-metadata">

### Author: ![Sparsh\_Singhal](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sparsh_singhal/32/13457_2.png) [@Sparsh\_Singhal](https://forum.kirupa.com/u/Sparsh_Singhal)
#### Post date: [January 29, 2021, 5:50am UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/5 "2021-01-29T05:50:39Z")

</div>

It was really helpfull. Your charts were were specially good.

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [January 29, 2021, 6:12am UTC](https://forum.kirupa.com/t/running-your-code-at-the-right-time/352075/6 "2021-01-29T06:12:50Z")

</div>

Thanks! Glad you liked them 😀
