I’m using Turbo to give my website a SPA feel. Whenever a link is clicked, it loads the
<body> of the destination using XHR and replaces the current page’s
<body> with the newly fetched one. Because of this, there’s never a full page reload and event listeners, etc. persist across pages, unless removed by JS.
So, I was optimising my JS to release memory that’s no longer needed, like removing
resize event listeners when the target elements no longer exist. However, the
slplayer.js seems to add a
resize event listener to the
window. It would be nice if that listener is added if any animation exists on page or if there’s a way to remove it when no longer needed.
It’s not a big deal as it’s just one event listener, but I’m just trying to get the memory footprint as low as possible.
I know, I can just refrain from adding the
slplayer.js file to my document, but since there’s never a page load, I need to keep the script in all pages.
I don’t really think there’s currently any way to do this, but just wanted to confirm. If there really is not any way, maybe one gets added in future.