Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option to remove elements from DOM with cosmetic filters #2211

Closed
rowaasr13 opened this issue Dec 3, 2016 · 1 comment
Closed

An option to remove elements from DOM with cosmetic filters #2211

rowaasr13 opened this issue Dec 3, 2016 · 1 comment
Labels

Comments

@rowaasr13
Copy link

Right now cosmetic filters simply add "display: none" to relevant elements - just as documented and as other blockers do with this class of filters. Is it possible to add an option to completely delete matched elements from DOM?

The goal of such option would be to futher reduce page's footprint which would be especially important to people who keep hundreds of tab open (like me).

If it is not possible on injection phase, some unique token can be injected along with "display: none" to style or attributes and then subsequent delayed pass can go over those elements and remove them after load.

@gorhill
Copy link
Owner

gorhill commented Dec 3, 2016

Element removal is not something to be used except maybe in very exceptional cases, such that this would maybe better left to a scriplet or special operator. The main issue is that removing elements may unleash mayhem in the DOM. Consider a filter such as:

###blah:first-child + div

Normally, only one element will be targeted by such filter. However if you remove the targeted element, an new one become targeted, until there is no more div to remove. So removing elements has a good potential to seriously change the semantic of existing filters.

At most I have entertained the idea of a :remove operator, but the need for it must be justified with enough real world cases.

For the stated reason, declined.

@gorhill gorhill closed this as completed Dec 3, 2016
Repository owner locked and limited conversation to collaborators Mar 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants