What if you loaded the script by default but cancelled the function on load?
Alternatively, if the JS is manipulating elements on the page, what if you used CSS classes? I.E a default ‘not-loaded’ class on your body element that the JS manipulates. Then have JS when loaded properly change the body class like ‘loaded’ and therefore that would respond to the JS in that circumstance?
@andy_unleash I’m confusing :p I want to trigger the same thing in two situations: , or .
I don’t want the external files (script or stylesheet) loaded by default. So basically I want to load JSON (for the example) only when the page is loaded. But, if the user stop the page loading because of the slow connection or something, it would also trigger the JSON to loading:
The main priority is that the function will triggered after the page successfully loaded.
A simple case: A loading animation layer that covered the whole page will appear before the page has been loaded, and will fade-out if the page has been loaded. But what if the page still does not loaded? If only I can make the layer invisible when users forcing to stop the browser loading, then that’s what I need.
By the way, my main goal is to load the JSON on two situations that I wrote above, because this part is quite important, but too large to be loaded in the same time with others and it’s likely will interfere with other loading processes.
It’s OK. I will also try to find the way in other places as well. If any…