Task #78975
closed
Refactor DOM ready check with AMD loader plugin domReady
Added by Gleb Levitin almost 8 years ago.
Updated almost 7 years ago.
Category:
Backend JavaScript
Description
In #70601 a lot of RequireJS AMDs were provided with a DOM ready check function to prevend their potential run into race condition.
The DOM ready check was taken with JQuery. It works, but in RequireJS there is an AMD loader plugin domReady for this purpose. It should be used instead.
Here is the appropriate API documentation and an understandable example:
http://requirejs.org/docs/api.html#pageload
- Status changed from New to Needs Feedback
We currently working on a migration to TypeScript, but this alone will not fix this issue, but now it is a good time to talk about other solutions like this one.
Can you explain what is the benefit of this plugin agains jQuery?
- Status changed from Needs Feedback to Closed
no feedback within the last three months, so I will close this issue for now.
I don't think we should use the requireJS domReady plugin since
- we basically have to deal with applications that are executed in a browser and jQuery's onReady handling in the root component handles that already
- the mentioned plugin has not been maintained during the last 2 years and has around 130 forks
- looking into the code reveals some "hacks", e.g. https://github.com/requirejs/domReady/blob/master/domReady.js#L86
Basically, maintaining an internal ready stack is similar in both jQuery and the requireJS plugin.
My conclusion: Let's stay with jQuery ready handling...
Also available in: Atom
PDF