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).
I need some JS to run once all dependent resources have loaded, so I use the window
load
event , ie.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).