2 ms·
SPA frameworks manipulate the DOM through JS, which means they need to take a reference to DOM elements. In a static website, once you navigate away from a pag
by torginus 5y ago
SPA frameworks manipulate the DOM through JS, which means they need to take a reference to DOM elements.
In a static website, once you navigate away from a page, the browser can deallocate all the DOM resources related to the old page, which can be quite heavy (images etc.).
In an SPA-driven website, the DOM is created by JS. Once you 'navigate' away (you tell the framework to render a different set of DOM components), the old ones still linger around in memory until the next GC cycle, meaning the browser has to wait for the GC to run before it can free them.
Even worse, GC's tend to be tuned for GC memory pressure, and if you have a ton of GC objects holding onto native resources, the GC has no way of telling it needs to run, because from its perspective, the GC heap is small and it has no idea about the native objects.
- jFriedensreich 5y agoStill dont get it. Obviously a dom implementation that is tied to a garbage collected script language has to be tied to the garbage collection in some way to free connected resources, this fact only shows that it is not a trivial task which is obvious. i still do not see how this is an argument why a garbage collected language is a bad idea for that usecase.