Mark
Mark

Reputation: 1

Opera extension

To put it simple: What's the fastest way to get the head element in an injected opera extension script ? (faster than waiting for DOMContentLoaded)

I insert a bunch of styles into loaded pages, and I'm not waiting for DOMContentLoaded (because the user wants to see the rendered css when the page loads, just like an usercss).

So I just get the head element (document.getElementsByTagName("head")[0] or document.head) and insert style elements into it; this works on most websites but I recently found out that it doesn't work on wikipedia because I can't get the head element without waiting for DOMContentLoaded.

PS: I know that Opera extensions are inserted before any other script so does that mean that the head element isn't loaded when the script is inserted ? So why does it work on some sites ??

Upvotes: 0

Views: 308

Answers (1)

hallvors
hallvors

Reputation: 6229

AFAIK, you can just do document.documentElement.appendChild() right away in your extension's script. The browser should sort things out just fine.

Upvotes: 2

Related Questions