- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024
11:56 AM
Instead of using DOMContentLoaded, you could try checking if the window is loaded.
window.addEventListener("load", () => {
// Do stuff
});
You could also set-up a MutationObserver. This should provide the quickest update once the detected content is loaded, but it is also more complex to set-up.
The Best Practices for Using Global JavaScript InstructureCon 2013 presentation also has an example of an onElementRendered function you could use to continue to check for an element and then do something once it finds it or stops trying after a certain number of attempts>