You can append a "load" event listener to elements, too. On images, this
event is fired as soon as the image ressource was loaded.
Testfile "gmtest.html"
> <!DOCTYPE html>
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> <!-- Some large pic that'll take a second to load -->
> <img id="pic"
> src="
http://www.geeknaut.com/images/windows-wallpapers/Winodws-7-aurora-wallpaper.jpg"
> width="1920" height="1200" />
> </body>
> </html>
Note that the following test script will only work if you set the
"greasemonkey.fileIsGreaseable" option in about:config to "true" during
the test. Don't forget to disable it later.
> // ==UserScript==
> // @name Test
> // @namespace LWChris
> // @include file://*gmtest.html
> // @version 1
> // @grant none
> // ==/UserScript==
>
> picLoad = function(evt) {
> document.title += " pic";
> }
>
> document.getElementById("pic").addEventListener("load", picLoad, false);
> document.title += " append";
You will see the title is "Test" from the HTML file, it's "Test append"
while the pic is loading, and "Test append pic" as soon as the image is
ready.
Chris