Question

'It is possible when using RequireJS to load scripts quickly enough that they complete before the DOM is ready.'

Well wait. What if the script is big and actually does not get loaded until AFTER the domloaded event in the browser? waiting for the domloaded event would lead to waiting forever. Or am I missunderstanding something?

I am actually using jquery for the ondomready event instead of their module. Do I have to worry about slow connections?

Was it helpful?

Solution

Both the domReady plugin and jQuery will detect if the page has already finished loading (i.e. if the DOMContentLoaded event has already happened). In this case, they will execute their callbacks right away. I've used them and never had a case where my code waited forever.

So you don't have to worry that a slow connection will cause them to wait forever.

If you believe you have encountered a case where they would wait forever, then please provide the details to reproduce it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top