It's due to the event hierarchy and the way mozilla performs content 
rendering.

The DOMContentLoaded event is the closest (and "best", if not only, in 
effect or actuality) event that can be used to perform Gm processing.

There is no "call me when the DOM is loaded, but BEFORE rendering begins 
(and don't start rendering until I return and/or am ready)" event in 
mozilla. If there was, that event would probably be used by Gm. There is 
also no "btw, don't start rendering yet" flag that can be set, or 
anything like that. Gm can only use what mozilla provides. (thereby the 
work-arounds suggested by people using userContent.css, etc., which are 
not automatic and require some manual labor by people if you want them 
to use those processes for your script)

Also, content rendering is an asynchronous process. After the DOM is 
loaded, rendering "begins" (in effect or actuality) and any processes 
(plural!) that have registered themselves with the DOMContentLoaded 
event are called. I don't know if it is on a "first come, first served" 
basis, or not, but that would be my guess. (but I could be wrong) AND I 
believe the calls to ALL of the processes who have registered themselves 
with that event are also called asynchronously, as well. So who knows 
how many functions get called before Gm. And what processing, and how 
much, is performed before Gm is called, or while Gm itself is executing. 
(depending on how threaded it all is, and how much "parallel processing" 
(if any, I'm not exactly sure how the internals work) is being performed 
by the Javascript processor, and the mozilla system) At that level 
things start getting a little complex as to what happens when, etc. 
(there are probably only a few people working on mozilla that understand 
and can answer these internals questions accurately with absolute knowledge)

And then there is the issue of what GmScript is called at what point, as 
well. Afaik, there is no way to say "ME FIRST!" for any script. 
(although I think the client (not the script creator) can tweak it 
manually) I forget how they are called. (probably either according to 
how they were added to Gm, or perhaps alphabetically, or maybe something 
else) This had been discussed before. So any number of GmScripts could 
also have been called and executed (and are executing, and used up some 
amount of time) before your script is called (all the while, rendering 
is occurring, and the time is in milliseconds or microseconds). I 
believe there is some amount of "parallel processing" involved there, as 
well. But, again, I don't know how all of that very low internal 
processing works in the mozilla JS system. (using sandboxes, etc.)

I don't know how some of the other addons do stuff before rendering 
occurs. Remember that there are also a bunch of addons that are called 
and executing in there, as well. (all of which are written in JS and 
XUL) I don't know when the addons are called, but probably "immediately" 
whenever mozilla thinks it's time for them to be called. But GmScripts 
need to execute AFTER the DOM is loaded (doing so otherwise, or before 
then, makes no sense, really), so that is when GmScripts are called, if 
not Gm itself. (I forget how that all works now, too)

Afaik, the above is fairly correct and true, but your mileage may vary.

Something like the above should be added to the wiki, but I'm not going 
to do it. In part because I don't know exactly how true and accurate my 
information is. (but I think it's pretty close, if not mostly right on, 
or thereabouts)


[email protected] wrote:
> this is something that is bugging me, everywhere i look the response
> is usually the same, which is no
>
> firefox renders as its loading the content and i can even understand
> why greasemonkey needs to have the full page before doing something,
> but i've seen extensions that do something before rendering the page,
> for example, adblock does it, why can't greasemonkey do it to? can't
> there be some sort of GM function that lets you do that?
>
> this bugs me because some sites take a while to load and i only see
> the result at the end, actually most of the time the page is fully
> loaded and it's just some sort of ad related content that it's taking
> a while to load
> >
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to