ok,disclaimer: I'm talking from my experience, I may not be right after all
:)
I understand you wanting to do things before onload,
and right after dom is loaded.
This however does not mean that scripts can not be on the bottom.
If you want to change the whole document before rendering
you definitely must wait for the whole html to be read by browser,
and if the page is big enough (a huge table 50x100 with loads of markup)
the rendering will start even before the whole document is read.
if you have an example of the page where it is a clear difference
when changing content before render and simply onload
I'm convinced I can make it work with scripts on the bottom.
.....
you can definitely hide the content before rendering and without a line of
js
the example is untested, but you can understand what I mean....
<div content ... style="display:none">
...content.....
</div>
<script .... js libs...>
<script>
//transform dom (all dom is loaded if the script is at bottom)
//show div
var div = document.body.firstChild;
div.style.display = "block";
//or remove div from body and move all it's children to body
document.body.removeChild(div);
while(div.firstChild){
document.body.appendChild(div.firstChild);//it will be removed from div
automatically
}
</script>
On Mon, Oct 6, 2008 at 9:45 PM, Onno Scheffers (JIRA) <
[email protected]> wrote:
>
> [
> https://issues.apache.org/jira/browse/TAPESTRY-2364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12637199#action_12637199]
>
> Onno Scheffers commented on TAPESTRY-2364:
> ------------------------------------------
>
> > this is simply untrue.
> > QUOTE: "Otherwise it is impossible to execute Javascript before the page
> renders..."
>
> You cut off the part of the sentence that really mattered.
>
> An onload-event is triggered when ALL resources are loaded (including
> images and script-files). The page starts rendering as soon as possible
> (even before the resources are loaded). Have you never seen the text popup
> in a browser before the images were loaded? That's the difference between
> dom:loaded and the onload event.
>
> This means rendering starts BEFORE the Prototype libraries are even loaded,
> which means the custom Javascript will be executed even later, since that
> relies on the Prototype libraries being loaded. It really is true. I can
> even prove it with example-code if you don't believe me.
>
>
> > A listener to onload can be added no matter where script tags are. onload
> will not be called until all page resources are loaded.
>
> Indeed, but the page will be rendered before the resources are loaded.. you
> can see the text appear in the browser before the images are loaded quite
> clearly.
>
>
> > you can always make content hidden, and show it after parsing it.
>
> But not before _rendering_ it!
>
> > YSlow Recommendation: Write Scripts at bottom of page
> > -----------------------------------------------------
> >
> > Key: TAPESTRY-2364
> > URL: https://issues.apache.org/jira/browse/TAPESTRY-2364
> > Project: Tapestry
> > Issue Type: Improvement
> > Components: tapestry-core
> > Reporter: Howard M. Lewis Ship
> > Assignee: Howard M. Lewis Ship
> > Priority: Minor
> > Fix For: 5.0.12
> >
> >
> > Tapestry is already doing a good job on this, by writing the dynamically
> generated <script> block at the bottom of the page, but the external scripts
> should also be down there.
> > http://developer.yahoo.com/performance/rules.html#js_bottom
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>