Details
-
Bug
-
Resolution: Fixed
-
Major
-
3.1
-
None
-
Unknown
-
Description
Most scripts are now loaded with defer, except prototype.js and xwiki.js.
It seems that we rely on the fact that xwiki:dom:loading and xwiki:dom:loaded would be triggered after all scripts are loaded.
But this is not true, xwiki:dom:load* is triggered during XWiki object initialization, and this object is created in a handler of prototype's dom:loaded event, which is itself an equivalent of DOMContentLoaded event with some fallback compatibility for non-supporting browser.
The DOMContentLoaded event is triggered when the DOM parsing is finished, and since deferred scripts do not interrupt DOM parsing and some browsers fire the DOMContentLoaded at the end of parsing (Gecko one in partcular), all scripts are not necessarily ready when the DOMContentLoaded event is triggered. Therefore:
- using xwiki:dom:load* in defered scripts does not ensure that the event will be trigerred,
- and using them in page content does not ensure that a related script will be available either.
The most visible issue of this is the LiveTable that is not initializing (case 1), this is particularly frequent in FireFox. The same is true for the table in RightsUI, which use a 'copy' of the same code.
The second (potential, since I have not reproduced it) issue is for viewers and widgets, for each the instance depends on the xwiki.dom:loaded event, which may occurs before the script being loaded and therefore observing the event.