Please consider some sort of “release ressources connected to a window when it is closed“ (stopping JS execution)

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
User avatar
pale guru
Moonbather
Moonbather
Posts: 69
Joined: 2021-11-06, 11:10
Location: Tyskland

Please consider some sort of “release ressources connected to a window when it is closed“ (stopping JS execution)

Post by pale guru » 2024-07-09, 09:22

While there are constantly more websites that are not able to send static HTML pages but scream for JS instead, at the time this “Morbus Featureetis“ is (ab)used to send data back home when the user closes the window. One example is
de.jackery.com/blogs/knowledge/wie-man-watt-in-ampere-umrechnet – as soon as you close the window it sends a POST to the web server.

Afai understand, this JS execution still happens in the context of the closed window. While I have tried to mitigate this unwanted tracking behavior over the last years with several plugins and addons, the only 100% safe way is to “unplug the network“ (ifdown) to avoid this transfers.

Would it be too complicated to just release the ressources of a window when it is closed (thus stopping JS execution immediately)?
… tanning in dimmed LCD light. – Evry 1′s a beginner, baby, that's the truth…

User avatar
Moonchild
Project founder
Project founder
Posts: 39641
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Please consider some sort of “release ressources connected to a window when it is closed“ (stopping JS execution)

Post by Moonchild » 2024-07-09, 10:32

It's not that simple. When you close a window, you aren't just "unplugging" that content from the internet; there are several web specs that require proper cleanup. Compare it to the difference between closing down an application normally (close X, Alt+F4, etc.) and killing it from a task manager or with kill -9 etc. (potentially leaving data unsaved, files open, databases dirty, etc.). There is even a specific "onbeforeunload" event handler in content to trigger events on purpose in content before it is unloaded (although that requires user interaction). Then there are workers/worker pools that operate disconnected from page documents, and more.

It's the reality of the modern web. You aren't just "loading a page" with discrete requests and responses. When you are interacting with these kinds of pages you are interacting with the server in real-time in a lot of cases, and you cannot easily avoid them getting a ping knowing when you unload the site in your browser. Hard-killing all resources would go against established web standards and likely break a lot of web functionality -- and your intended goal of preventing this POST pinging the server to know when you left the site won't easily be avoided, nor very useful (as the server will still know when you left, from context).

You may be better off just blocking that specific POST request with a tailored content blocker filter.
"Sales hates anything that can't be turned into a confident sentence." - anonymous warehouse worker
"Why debate someone you fundamentally don't trust?" - Dario Amodei
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite