Firefox Add-On: window.addEventListener( "load", init ) not firing event

  firefox-addon, javascript

Found a similar thread on stackoverflow, but other than "it should work", no solution was given.

I’ve written a simple Firefox add-on that works flawlessly most of the time. But sometimes after I restart FireFox, it doesn’t. It runs, but its initialization event is never fired. The code is:

window.addEventListener( "load", ts_init );
console.log( "TS plugin loaded." );

function ts_init() {
  console.log( "init" );
  // Do other stuff

Like I said, most of the time it works perfectly but sometimes it loads (I see the "TS plugin loaded." message) but the load event is never fired (I don’t see the "init" message and the plugin is never initialized). Neither reloading the add-on, nor refreshing the page, nor restarting Firefox helps. Even if I strip down the init() function to just the console.log( "init" ) line, the event is never fired. I just have to wait until it suddenly starts working again- usually after a few days.

There are no errors in the code so this apparently is a FireFox problem. Anyone any idea what might be causing this?

Source: Ask Javascript Questions