[Greasemonkey] Page-load jumpiness
zboogs at gmail.com
Thu Apr 28 13:15:27 EDT 2005
> Can a script control "nglayout.initialpaint.delay"? Would that help?
> Could you set that to some large number at the start of your script
> and reset it to zero at the end?
This is a good idea. Greasemonkey could set this value programatically
if there are >0 scripts which apply to this page. It could even
(theoretically) keep statistics and tune this value over time.
I'm totally ready for any help on this issue. Here are the ways I have
* Get an event notification when the document instance is finished
being built and use the DOM to add script elements. This is how it
currently works, with the DOMContentLoaded event. However, the browser
seems to allow the page one render pass before this event fires so
it's often a noticeable delay between "finished" and "greasemonkeyed".
* Manipulate the source code directly as it comes off the wire using
the mimetype hack. I'm fine with the unfrozen interfaces (we could
always change it if this breaks), but I'm told that this will require
really slow. I've not tested it's performance though.
* Extend the BODY element with XBL to add the script elements to the
end. This is the most elegant of all approaches but SCRIPT elements
are never evaluated due to an outstanding bug.
* You could use XBL's <constructor> element, either on BODY or SCRIPT
tags injected by the above approach, but <constructor> is run at a
non-deterministic time -- on large documents, even before the entire
DOM is available. Additionally, this often occurs to run well after
DOMContentLoaded from my tests.
Basically, incremental loading is the enemy :-). Another thing that I
would like to try is to get notifications when each chunk is complete.
I don't know how to do this. Mozilla people have told me that it might
be possible to register a new content sink to do this, but that would
definitely be C hacking.
The two best approaches seem to be this last one and the stream
mimetype one above. Both require C. I suck at C.
More information about the Greasemonkey