Remove page html from Dom when page is not active


#1

Hello everyone,
There is a way that the page html will not be in Dom when page are not active?

What happens not is each page i open is add his Html to Dom its not good for performance


#2

Pop pages off the nav stack when you aren’t using them.


#3

If i will pop off the pages the history stack removed.
I want to keep history


#4

You could store the history in a provider. Or you could clean up your page in ionViewWillLeave.


#5

How do i clean up my page?
Any example?
Thanks


#6

Pages are not in the dom when they are not shown, per mechanism of angular

So your question may need to be rwphrased to express what you are trying to clean and moreover: why?

Much of garbage collection, loading and dom handling is within angular or even js


#7

Unsubscribe from all Observables, for example. Disconnect change detection (though that can be dagerous-ish). It depends on why your pages are not performant. But these steps are probably unnecessary if you refactor. I don’t think this is an inherently Ionic/Angular problem. Something you are doing is costing more than it needs to.