where is the best place to place a javascript snippet to alter the DOM of a page before it renders
Posted
by icepack
on Stack Overflow
See other posts from Stack Overflow
or by icepack
Published on 2010-04-28T10:01:59Z
Indexed on
2010/04/28
10:13 UTC
Read the original article
Hit count: 321
I have a few dynamic pages and I want to alter certain elements before the page has fully rendered.
My snippet is something like
document.body.getElementById("change").innerHTML = "<img src...";
I do not have access to change the content server side.
Where is the best place to put the snippet to have the code run before the page it has rendered?
Rather, is putting the javascript in either the HEAD (inside the window.onload event?) or before the closing BODY(not inside an event listener) optimal?
© Stack Overflow or respective owner