Add a simple TV, choose type Text, then reference in template like:
<body onload="[*onloadTv*]">
(in this case I have TV named onloadTv).
OR if some documents dont have onload altogether, use something like this:
<body [*onloadTv*]>
while add a onload="preloadImages();" in tv content