-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
enhance(noscript): better handling of JS-disabled-or-not-working states #3852
Conversation
Quick links (staging server):
Login:
SVG tester:Number of differences (default views): 0 ✅ Edited: 2024-08-06 14:13:42 UTC |
I just changed This is what this looks like now on desktop without JS (pending the fix in #3864): |
…mediately getting updated on load
The case when JS is enabled, but the script is blocked, seems very rare. Are we aware of this happening in the wild (and the user expecting it to work)? IMHO, the additional complexity of supporting it is not worth it, but I might be missing something. |
@rakyi You mean the code over here, right? owid-grapher/site/NoJSDetector.tsx Lines 41 to 56 in 394d7c2
I'm not certain how common it is, but two scenarios where it can happen are:
I don't think the 15-or-so lines needed to handle that case are too bad. The other JS-is-enabled-but-not-working case is the one of try {
const regex = /\p{L}/ui
} catch {
} will lead to a SyntaxError in Firefox <78 for using However, catching a SyntaxError is no easy feat, since it can pretty much only be caught using a global |
(Just wanted to quickly jump in here and say thanks for working on this :) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain how common it is, but two scenarios where it can happen are:
My hunch is that it's not worth it to support that, but I might be wrong.
will lead to a SyntaxError in Firefox <78 for using
\p{L}
, and also in Chrome <66 because ofcatch {}
rather thancatch (e) {}
.
We even declare that we don't support these versions of those browsers, so I'm surprised that we now add code to support them. Do we have analytics on how many users use them?
Otherwise, nice work, LGTM! None of the above is blocking, up to you if you want to change anything.
This PR resolves most of the cases where we weren't handling a browser with JS not enabled or not working properly (e.g. old browser) nicely.
There are still a few cases that could see improvements, but we have a good foundation now, mostly based on the mutually-exclusive
js-enabled
/js-disabled
classes on the<html>
element.This all is way more involved than you'd think: See https://github.com/owid/owid-grapher/blob/noscript/docs/browser-support.md#detecting-disablednon-functioning-js for all the details of this.
There's also a long companion video on Slack: https://owid.slack.com/archives/CQQUA2C2U/p1722965563740379
One before/after example
(styles can be improved 😁)