Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History.JS running settimeout every second because of IE8. #321

Open
leonardoanalista opened this issue Jul 25, 2013 · 7 comments
Open

History.JS running settimeout every second because of IE8. #321

leonardoanalista opened this issue Jul 25, 2013 · 7 comments

Comments

@leonardoanalista
Copy link

I've just searched and haven't found exactly the same issie open.

I am using jquery.history.js. On the line 3247 you have this code:

// For Internet Explorer
History.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));

as well as this code too:

// For Other Browsers
History.Adapter.bind(window,'beforeunload',History.onUnload);
History.Adapter.bind(window,'unload',History.onUnload);

This code will trigger a clean up on history local storage when user leaves the page. I know that IE 8 has got issues with unload event.

However, all other browsers are being "punished" with this settimeout running every second because of IE8. It seems to be unnecessary as the cross-browser unload can be achieved with this code:

window.onbeforeunload = beforeQuit;
function beforeQuit(){
    return "Do you really wanna quit?";
}

My point is: All other browsers don't need to have this settimout function running all the time. I am building mobile web apps and I am concern about possible battery draining issues.

What do you think?

Btw this library is great man! you guys are doing a f great job!

cheers
Leoanrdo

@duantihua
Copy link

I agree with this.

@barbagallo
Copy link

I agree as well.

The plugin is awesome, however..the unnecessary polling seems to be a hit on performance.

@lephyrius
Copy link

I agree!
Hope this gets fixed!

@danatcofo
Copy link

simple alternative, doing this in local version of file

// For Internet Explorer
// target only at IE
if (History.isInternetExplorer())
    History.intervalList.push(setInterval(History.onUnload, History.options.storeInterval));

@leonardoanalista
Copy link
Author

I just removed those lines at all as we supported only HTML5 devices. I reported more as an improvement.

dannycroft pushed a commit to dannycroft/history.js that referenced this issue Feb 17, 2014
…ecessarily

- Primarily for non Internet Explorer browsers
dannycroft pushed a commit to dannycroft/history.js that referenced this issue Feb 17, 2014
- Only trigger setInterval for IE8 and below
dannycroft pushed a commit to dannycroft/history.js that referenced this issue Feb 17, 2014
…ecessarily

- Primarily for non Internet Explorer browsers
dannycroft pushed a commit to dannycroft/history.js that referenced this issue Feb 20, 2014
…ecessarily

- Primarily for non Internet Explorer browsers
@drulia
Copy link

drulia commented Feb 24, 2014

My application on chrome because of this, every second has memory being filled up with almost 1mb of data. Of course, data is garbage collected after a while, but in the mean time, it just causes constant growth of memory usage.
The worst thing is, it actually causes constant growth of memory usage over time, which kind of indicates that there might be some leakage after all. Having no setInterval running allows tab memory usage stay still.

@evil-shrike
Copy link

Hi.
Is there any chance someone will resolve (I'm even not saying 'fix') this issue some day?
Many people encountered this strange behavior and reported different issues, see:
#376 , #397 , #340

It's really unclear WHY to call History.onUnload in ALL browers EVERY SECOND.
Strictly speaking there're no a memory leak but it burns battery on mobile and disk everywhere with useless I/O.
If it's really necessary (I can admit it is) then it'd be nice to write down some explanation in code or wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants