Skip to content
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

Javascript window load event fires inconsistently #126

Open
lvlte opened this issue Feb 20, 2023 · 0 comments
Open

Javascript window load event fires inconsistently #126

lvlte opened this issue Feb 20, 2023 · 0 comments

Comments

@lvlte
Copy link

lvlte commented Feb 20, 2023

I need some JS to run once all dependent resources have loaded, so I use the window load event , ie.

window.addEventListener('load', function(event) {
  console.log('window.load');
});

But for some reason it won't fire consistently, I would say the handler is executed 1 time out of 10.

If I use document.addEventListener('DOMContentLoaded', handler) though it works fine, but the script then runs too early, especially on htmlpreview where the css files seem to take a long time to load and execute (compared to the js files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant