You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
addEventListener("DOMContentLoaded", ...) never runs? #87
This is because the scripts are being fetched and run after DOMContentLoaded event, so the solution is to use load event instead or check if DOMContentLoaded event has been fired:
Rawgit is a third-party proxy server and could theoretically shut down at any time, while HTMLPreview is a client-side project without third-party servers (with an exception of external JS/CSS scripts, which are being proxied due to CORS). Because of this, the scripts are deferred and run past the DOMContentLoaded event. I can experiment with manually dispatch DOMContentLoaded event, but I am afraid this could have side effects on existing scripts (double dispatch).
@MaxLOh Do you mean getEventListeners()? It's only in Chrome DevTools. But I can manually dispatch DOMContentLoaded event like this: document.dispatchEvent(new Event('DOMContentLoaded', {bubbles: true, cancelable: true}));, although it may have side effects, which I wrote above.
Activity
niutech commentedon Oct 7, 2020
This is because the scripts are being fetched and run after
DOMContentLoadedevent, so the solution is to useloadevent instead or check ifDOMContentLoadedevent has been fired:jason-s commentedon Oct 7, 2020
Nope, then the solution is to use another service then.
This is a bug.
Rawgit.org works fine: https://ghcdn.rawgit.org/jason-s/embedded-blog-public/master/demos/gravity1/gravity1.html
niutech commentedon Oct 7, 2020
Rawgit is a third-party proxy server and could theoretically shut down at any time, while HTMLPreview is a client-side project without third-party servers (with an exception of external JS/CSS scripts, which are being proxied due to CORS). Because of this, the scripts are deferred and run past the
DOMContentLoadedevent. I can experiment with manually dispatchDOMContentLoadedevent, but I am afraid this could have side effects on existing scripts (double dispatch).max-hk commentedon Oct 12, 2020
How about running all functions returned from getEventListener(document).DOMContentLoaded?
niutech commentedon Oct 13, 2020
@MaxLOh Do you mean
getEventListeners()? It's only in Chrome DevTools. But I can manually dispatchDOMContentLoadedevent like this:document.dispatchEvent(new Event('DOMContentLoaded', {bubbles: true, cancelable: true}));, although it may have side effects, which I wrote above.