Skip to content

Javascript window load event fires inconsistently #126

Open

Description

@lvlte

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions