Closed arvgta closed 2 years ago
Just for the sake of completeness - this approach has been discarded in the course of some testing...
Our partner AllMediaLab has reported, that there are still issues with DOMContentLoaded
handling - thus reopening
Our partner AllMediaLab has reported, that this is not an issue with DOMContentLoaded
handling after all - thus closing again
When using Ajaxify, the
DOMContentLoaded
event is not fired every time around i.e. only on initial load.Lots of sites that translate e.g. the old jQuery
ready()
event to native JavaScript use theDOMContentLoaded
event instead. In order to assist such porting, we have introduced the following piece of code...... which is suspected to be buggy:
At the very least the
setTimeout(b)
bit seems dodgy, because theb
handler is being called at the time of registering the handler, which can cause timing problems, that have been reported on some sites.The above logic is enabled by default (
intevents: true
)A different and possibly cleaner approach might be to programmatically trigger
DOMContentLoaded
, in case the user wants that?Something like this:
Now that I made the transition, the next problem is how to avoid duplicate attaching of any event handlers?
If necessary, I would like to ensure that the handlers are only triggered once by using the modern
{ once: true }
technique: