Re: History navigation and DOM + JS context

Boris Zbarsky <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Manoj Punjabi wrote:
> An observation I made with FF 3.0.10 is that history navigation sometimes
> results in a JavaScript re-initialization but other times it does not.

That's correct.

> I think it depends on the complexity of the script but I do not have any
> concrete answer at this point. It seems like FF is making some determination
> on when it is worth it to cache the DOM / JS Context vs. when to start over
> again.

Yes.

> What determines this behavior?

Whether the page has unload or beforeunload handlers, whether there are 
loads still happening during the navigation, whether the page is in a 
subframe, and probably another half-dozen things I'd have to look at the 
code to see.  All of this is subject to change without notice.

> (FWIW: In IE and Chrome, the JS / DOM is re-initialized on each history
> navigation)

Sure.  The question is... why does it matter?  Fundamentally, history 
navigation is not that different from tab switching (which doesn't 
reinitialize anything).  Ideally we'd always be able to go back in 
history to exactly what the user saw without reloading anything; the 
only things standing in the way of that are memory constraints and some 
technical difficulties with restoring certain kinds of state.

-Boris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.