I’m developing my first NUI, and after finishing it, I was impressed by the number of elements I used in HTML/CSS/JS. And this is just one NUI out of many others the server will have. This specific NUI will only be used once per session by the player, and after that, it won’t be needed anymore.
So, I’d like to know if there’s a commonly used method among FiveM developers to completely unload a specific HTML/CSS/JS from memory. I don’t think simply setting it to hidden in the HTML is enough, as that would only hide it while the JS variables, CSS, and all elements would still remain in memory.
That means every time I set the NUI to true, even if it was for another NUI, all those previous resources would still be occupying the client’s memory, potentially turning the experience into a real nightmare.
I got it, destroy my EventListeners, destroy my HTML with react, I confess that I will have to learn react, but it’s for a good cause, in the case of this NUI mentioned, it has some resources that are a little heavy, yes, many Listeners, audio and other things, thanks for your answer!