How do I load my main JavaScript AFTER JSON data was loaded?

I have some event listener that are connected to elements that are loaded together with JSON data. How do I load them AFTER JSON data was loaded?
11 Replies
b1mind
b1mind•2y ago
Async and defer loading.
Dovah
DovahOP•2y ago
What is that? xD
b1mind
b1mind•2y ago
Async Vs Defer - JavaScript Loading Explanation
An explanation of the difference between standard, async, and defer script tag loading, and which is the best to use.
b1mind
b1mind•2y ago
Learning to search is your best tool as a dev (I gave you words to use). Here is a great article about it though.
Dovah
DovahOP•2y ago
Thanks! I will look through it! But do I need to split JS files?
b1mind
b1mind•2y ago
Also I have no clue how your loading json
Dovah
DovahOP•2y ago
for that? I just have fetch() thing
b1mind
b1mind•2y ago
It's it a async ? 😶
Dovah
DovahOP•2y ago
So I have 1 JS file, called in the bottom of my body tag, just script with source. Top of JS file is fetch() json thingy that creates elements based on data, and below all that I wrote some EventListener's connectecd ot those elements. I just don't know how to execute them after I have all the data loaded. Haven't yet read the article so I don't know if it is async or not. Or waht that means xD
b1mind
b1mind•2y ago
Different async as in async function with await fetch. You will want to look that up too Both things will play a big part
Dovah
DovahOP•2y ago
Roger. Thanks for the info.
Want results from more Discord servers?
Add your server