defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.73k stars 1.97k forks source link

PJAX memory Leak issue #709

Open cablegunmaster opened 6 years ago

cablegunmaster commented 6 years ago

$(document).on('pjax:beforeReplace', function (contents, options) { //might prevent memory leak $(contents.target).empty(); }

This should be added to the memory to prevent memory leak and keep adding old nodes to new nodes if you use PJAX. This unloads all Events from former PJAX pages and should only be used when you have it set on 1 page.

I put this here to see if this is the right approach, and or to fire some ideas upon it. Before making a pull request for it.

PuiMan Cheui also made an similar issue for it. https://medium.com/front-end-hacking/pjax-react-2ee247af0fb5

BlackSwan22 commented 4 years ago

$(document).on('pjax:beforeReplace', function (contents, options) { //might prevent memory leak $(contents.target).empty(); }