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
Async and defer loading.
What is that? xD
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.
Learning to search is your best tool as a dev (I gave you words to use). Here is a great article about it though.
Thanks! I will look through it!
But do I need to split JS files?
Also I have no clue how your loading json
for that?
I just have fetch() thing
It's it a async ? 😶
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
Different async as in async function with await fetch. You will want to look that up too
Both things will play a big part
Roger. Thanks for the info.