jonathantneal / document-promises

Document loading states as Promises
Creative Commons Zero v1.0 Universal
53 stars 7 forks source link

contentLoaded isn't accurate #3

Closed jakearchibald closed 8 years ago

jakearchibald commented 8 years ago

If this runs in a script that has defer, contentLoaded will resolve before the DOMContentLoaded event.

I'm not sure if there's a way around this, since readyState can equal "interactive" both before and after DOMContentLoaded.

It's at least worth noting it isn't accurate.

jonathantneal commented 8 years ago

I should add it as a known limitation. BTW, how did you even find this?

jonathantneal commented 8 years ago

Resolving this via https://github.com/jonathantneal/document-promises/commit/ff64983175d4c528f518802482e618c0c42aace4

jakearchibald commented 8 years ago

How did I find the problem: the HTML spec. How did I find this repo? https://twitter.com/lucasmazza/status/790918537716047873

There may be other cases where contentLoaded fires at the wrong time btw, but as far as I can tell it'll only ever be early, not late or never-happening.