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?
I had the same issue once. This is an issue that has to do with caching AFAIK. There's also a JQuery Bug Report describing the same issue.
The Solution for me was using the pageshow event. The linked MDN page has a good example how to use it. I hope it helps! :D