Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-6754

Flickering Javascript errors and issues due to bad initialisation



    • Unknown


      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:

      1. using xwiki:dom:load* in defered scripts does not ensure that the event will be trigerred,
      2. 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.




            softec Denis Gervalle
            softec Denis Gervalle
            0 Vote for this issue
            1 Start watching this issue