captain dragon captain dragon - 1 month ago 6
HTML Question

html injection using JS event

I wanted to know what is the primal event to use for injecting HTML code.

the Javascript code itself is injected using a chrome extension.

the HTML code is a message which should appear on top any other HTML.
moreover, it should appear to the user before the other html elements or as soon as possible.

I've looked for the right event and stumble upon with

. The problem is, the
<div id="message">
is rendered after all the dom tree has loaded and that's not good enough for me.

is there another event for this cause?


p.s. HTML5 is an option for me if needed..


Well, jQuery have $(document).ready() function which is fired, when all DOM elements are ready. It is faster than window.onload function. Here is question about how get document.ready in clean JavaScript: $(document).ready equivalent without jQuery