Something like a [SameValue] attribute Promise<void> loaded; on HTMLScriptElement would be nice, where it's resolved immediately with the load event itself when the script completes execution and rejected immediately with the error event itself if/when an error occurs.
Currently, there is no way to tell if a script is loaded or not, and that would be very useful in a lot of contexts, particularly when the script is in the HTML itself and might not yet be loaded.
This is possible to polyfill, but only for scripts you can control the loading of. Conceptually, it's as simple as this:
script.loaded = new Promise((resolve, reject) => {
script.addEventListener("load", resolve, false)
script.addEventListener("error", reject, false)
})
Something like a
[SameValue] attribute Promise<void> loaded;onHTMLScriptElementwould be nice, where it's resolved immediately with the load event itself when the script completes execution and rejected immediately with the error event itself if/when an error occurs.Currently, there is no way to tell if a script is loaded or not, and that would be very useful in a lot of contexts, particularly when the script is in the HTML itself and might not yet be loaded.
This is possible to polyfill, but only for scripts you can control the loading of. Conceptually, it's as simple as this: