Nok Imchen
Nok Imchen

Reputation: 2842

Is there any addon that can make javascript execute before the page loads?

Well, greasemonkey can execute users script but only after the page loads fully. Is there any script that can take user script (javascript) and executes it before the page downlaods any elemts. for instance, As soon as the HTML file is downloaded, the user script should execute so that i can prevents the download of embedded elements like flash, jpg, js files downloads

Upvotes: 4

Views: 623

Answers (1)

Nickolay
Nickolay

Reputation: 32063

There's a content-document-global-created notification in the recent versions of Firefox that fires before the page started loading.

Jetpack SDK has a Page mods module that uses that notification to let you write greasemonkey-like snippets. That's kind of an "addon that can make javascript execute before the page loads".

I don't know how you'd implement content blocking via such script, though.

The common way to do content blocking is via nsIContentPolicy, which is what Adblock uses.

Upvotes: 3

Related Questions