Window load event is not firing

I have a super simple extension to handle when the web page loads. This is what I have:

window.addEventListener(‘load’, pageLoaded);
function pageLoaded() {
alert(“winpicker pageLoaded() called…”);
}

alert(“winpicker extension 1.0 is loaded and running…”);

I do see the last alert box but not from pageLoaded. Any ideas, please?

UPDATE:
+++++++
I have specified “matches”: ["<all_urls>"]
in the manifest.json and tested many different pages. Only a handful of pages actually fire the page-loaded event! Most do not fire.

I tried clearing the browser cache, but it made no difference.
and I have not figured out why only certain pages trigger the event.

Content scripts are by default injected after the page is loaded, so the event won’t fire if the code is executed after the page is already loaded.

See also:

To fix it, you can use “run_at” value “document_start”.

hi thanks a lot for the pointer!
with run_at/document_start, many more sites “work” but not reliably,
whereas in Chrome, the extension worked (without run_at) in nearly all sites i tried.

notably, on engadget.com and news.yahoo.com,
extension script did not load at all on both chrome and firefox!

The easiest solution would be:
Don’t use an event listener at all, because

Right. When and if the script is loaded, the page has been loaded by design!

Is there a way to notify page-loaded event to another app running in the local machine? I’m running Kubuntu and thought of a simple text file but that’s not allowed. D-bus signal would be nice but probably not possible in javascript.