问题
We have implemented the revolution slider (jQuery version, not WP) into a page of ours. This page must stay open for an extended period of time and reloads the revolution slider at set intervals using Ajax with new/updated content.
How do we remove the slider completely from the DOM at runtime? I've used .remove() on the variable I initialized the slider with, but it appears that some of the events/functions of slider are still running. It works as we planned, but I feel that the remove() function doesn't completely remove the slider from the DOM because an occasional console error will pop up even after the slider has been removed with the remove() function and not reinitialized again. Any help/insight into the matter would be great!
Thanks a bunch!
回答1:
I've discovered a solution to the problem I had with the Revolution Slider. So, the issue with this slider and Ajax is the fact that there is no native way to fully remove the slider and all of it's timers and events. This therefore causes a massive memory leak and over the course of about 12 hours accumulates 1.5 gb of memory (running in Google Chrome on a Mac) and causes a crash of the browser.
The solution: Place the slider, along with all of it's code inside of an iframe. This allows the slider to be initialized inside of the iframe and allows for us to completely remove the slider from the page by removing the iframe and then reloading the slider with fresh content in a new iframe. No more memory leak, no more problems.
Cheers! I hope this helps someone out there.
来源:https://stackoverflow.com/questions/25085044/revolution-slider-jquery-version-not-wp-version-re-initialization-at-runtime