Skip to content

Let users disable hiding some newsfeed events - #988

Merged
sindresorhus merged 1 commit into
masterfrom
show-me-what-you-got
Jan 17, 2018
Merged

sindresorhus merged 1 commit into
masterfrom
show-me-what-you-got

Conversation

@fregante

@fregante fregante commented Jan 13, 2018 •

Copy link
Copy Markdown
Member

I figured a couple more lines of code are worth it

screen shot 2018-01-13 at 14 02 28

Closes #747

@sindresorhus

Copy link
Copy Markdown
Member

It's not just a couple of more lines. It also means it will happen much slower since it has the execute the JS before hiding instead of just being in the CSS.

@yakov116

Copy link
Copy Markdown
Member

@sindresorhus True, But I think many users will be very happy with this addition.

@sindresorhus

Copy link
Copy Markdown
Member

I don't think we should do this. It's a slippery slope and not how we should handle opt-out of CSS. There are better ways to enable opting out of CSS changes than rewriting it to JS. We should always prefer CSS when possible.

@sindresorhus

Copy link
Copy Markdown
Member

@yakov116 This extension has 10.000 users and only a few have complained so far.

@yakov116

yakov116 commented Jan 14, 2018 •

Copy link
Copy Markdown
Member

@sindresorhus True. Not that it makes a diff, I recompile just because of this change.

@fregante

fregante commented Jan 14, 2018 •

Copy link
Copy Markdown
Member Author

It also means it will happen much slower since it has the execute the JS before hiding instead of just being in the CSS.

The script is always run before the first paint so this shouldn't happen. All of RGH's JS still needs to be parsed/executed before the first paint so it really is no more than a couple additional calls. It can be shortened to document.body.classList.add(...) but that'd be over-optimization.

I don't see much of a problem with something as simple as this, but if it looks too much like a slipper slope we can just close #747 and direct everyone to undo the change with Stylish.

@sindresorhus

Copy link
Copy Markdown
Member

I'm not against the intention of the change, just feel that we should rather solve the problem of many disabled features depending on CSS and how to have it disabled too, rather rewriting all of the dependent CSS in JS.

@fregante

fregante commented Jan 14, 2018 •

Copy link
Copy Markdown
Member Author

disabled features depending on CSS and how to have it disabled too

Same solution: leave the rules in the CSS but hide them behind a class.

There are better ways to enable opting out of CSS changes than rewriting it to JS. We should always prefer CSS when possible.

Such as? Stylish? That's not always easy though. In this case it's just a display:none -> display:block; in others it's more than one prop and rule.

@sindresorhus

Copy link
Copy Markdown
Member

Same solution: leave the rules in the CSS but hide them behind a class.

But I would like the inverse. I don't want to make the default case worse in any way, even if it's super minor (It adds up).

@sindresorhus

sindresorhus commented Jan 14, 2018 •

Copy link
Copy Markdown
Member

I can't really think of a good solution right now though.

Maybe a compromise would be to, as soon as document.documentElement is available, to add a class for all the features to document.documentElement.classList(). And if something is disabled we wouldn't add it. Then we could scope CSS tweaks under the relevant feature and it would just not be selected if the feature is disabled. (We wouldn't do this for everything. Just JS features that when disabled would not be fully disabled or broken without disabling the CSS)

@fregante

fregante commented Jan 14, 2018 •

Copy link
Copy Markdown
Member Author

even if it's super minor (It adds up).

I don't think such solution exists. Either way there's some more code to write/parse/execute/maintain and it's nothing saved (we can discuss this on a case by case basis)

add a class for all the features

We don't have a list of features, it's just filenames, unless there's a webpack plugin that adds the array of modules to the bundle.

add a class for all the features to document.documentElement.classList()

This is essentially what this PR does, except it's localized in its own feature file instead of being global. It doesn't get any faster than this (i.e. run in init, adds a class right away)

@sindresorhus

sindresorhus commented Jan 14, 2018 •

Copy link
Copy Markdown
Member

We don't have a list of features, it's just filenames, unless there's a webpack plugin that adds the array of modules to the bundle.

Would be easy to make that if needed.

This is essentially what this PR does, except it's localized in its own feature file instead of being global. It doesn't get any faster than this (i.e. run in init, adds a class right away)

I just don't like using JS for something that already works fine with CSS. You're right, this is just a one-line thing, but this opens the door for people to ask about CSS changes to other disabled features too. Shouldn't we think further ahead than just this change?

@fregante

Copy link
Copy Markdown
Member Author

We’re talking about two separate things in the same discussion:

  • enabling CSS feature via JavaScript (this PR)
  • fully disabling JavaScript features by toggling the CSS via JS

For this specific PR: it’s fine either way.

I’d merge it because even 10 of these aren’t a big deal to me and the user request makes sense.

We can also close this because this specific feature can easily be undone via Stylish.

@sindresorhus

Copy link
Copy Markdown
Member

Yeah, gonna merge this since it's such a tiny change and many seem to want it. I do think we should discuss a better way to handle the CSS of features at some point though.

@sindresorhus
sindresorhus merged commit 9d37a8a into master Jan 17, 2018
@sindresorhus
sindresorhus deleted the show-me-what-you-got branch January 17, 2018 13:03
@fregante

Copy link
Copy Markdown
Member Author

I do think we should discuss a better way to handle the CSS of features at some point though.

Wait for the next feature or open a new issue now? :)

@sindresorhus

Copy link
Copy Markdown
Member

We can wait for the next feature. Easier to discuss something based on actual code.

@fregante

fregante commented Mar 5, 2018 •

Copy link
Copy Markdown
Member Author

We can wait for the next feature. Easier to discuss something based on actual code.

Is #1122 a good candidate for discussion?

I don't think that there's a better solution than hiding the CSS behind a class like in https://github.com/sindresorhus/refined-github/pull/1089/files#diff-a58403778295001c22a20116c193c4a1

The class is added right after body is available: (first and last line of this snippet)

https://github.com/sindresorhus/refined-github/blob/ee97b60204ce2d641bc58aa7dc6dddbcd58bf879/source/content.js#L79-L123

@sindresorhus

Copy link
Copy Markdown
Member

Is #1122 a good candidate for discussion?

Not really. See my comment there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants