-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Appropriate handling of DOMContentLoaded event #216
Comments
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 |
Our partner AllMediaLab has reported, that this is not an issue with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:The text was updated successfully, but these errors were encountered: