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

doc(adr): Add non-javascript support adr #1720

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions doc/adr/0021-users-without-javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 21. Supporting Users Without JavaScript

Date: 2025-02-11

## Status

Accepted

## Context

Currently, our application is built with the principle that core functionality should be accessible and usable even without client-side JavaScript.
This aligns with our goal of ensuring a resilient and broadly accessible experience.

We recognize that "non-JS users" aren't just those with JavaScript disabled, but also include users with slow connections, JavaScript errors, or while the JavaScript is still downloading ([Everyone has JavaScript, right?](https://www.kryogenix.org/code/browser/everyonehasjs.html)).
However, we are now encountering situations where specific features, like the upcoming upload component or the auto-suggest input, require JavaScript to work intuitively.
Our approach needs to address the balance between rich interactive features (requiring JavaScript) and the core usability for all users.

Our framework Remix is built with progressive enhancement in mind, providing a functional experience even during JavaScript loading or failures.

## Decision

We will adopt a [**Progressive Enhancement**](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement) strategy for all features.
This means:

1. **Core Functionality First:** All essential features must be fully functional and accessible without JavaScript. This ensures that every user, regardless of their JavaScript capabilities, can accomplish the primary tasks the application is designed for.

2. **Enhancement with JavaScript:** JavaScript will be used to _enhance_ the user experience where appropriate. This allows us to add interactive elements, richer interfaces, and improved performance for users with JavaScript enabled. Examples include the auto-suggest input, dynamic form validation, and advanced UI components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without JavaScript, what happens when the user enters invalid data? for example, if they enter an option not included in an auto-suggest? or enters an invalid number? is that data saved?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already run the same (or stricter, see post code) validation on the backend before saving (otherwise this would also be a huge security issue).

This also helps with the no-JS case, as rvf consumes the schema violations returned by zod + previously sent data and rebuilds the form. It works so magically that we don't have to think about it..

So: Data is always submitted via POST request on hitting the SUBMIT button, the server does the schema validation and redirects to a another page. On invalid data without JS, the same page is returned, this time with errors attached to the offending form fields.


3. **Graceful Degradation:** If JavaScript fails to load or execute, the enhanced features should degrade gracefully, ensuring that the core functionality remains intact. This might mean a less visually appealing or less interactive experience, but it should never result in broken or inaccessible functionality. Components should be designed in isolation to minimize the impact of JavaScript failures.

4. **Testing Strategy:** Our testing strategy will include both JavaScript-enabled and JavaScript-disabled scenarios. This will ensure that we are continuously validating the accessibility and functionality of our application for all users.

This is also suggested by the GOV.UK Service Manual for the governmental area (see [here](https://www.gov.uk/service-manual/technology/designing-for-different-browsers-and-devices) and [here](https://www.gov.uk/service-manual/technology/using-progressive-enhancement)).

## Consequences:

- **Positive:**

- Improved accessibility for users with disabilities, limited bandwidth, or JavaScript disabled/unavailable.
- Increased resilience to network issues and JavaScript errors.
- Simplified testing of core functionality.
- Alignment with best practices for web development.

- **Negative:**

- Increased development effort for implementing features in both a non-JS and JS version (though this is mitigated by focusing on core functionality first).
- Potential limitations on the complexity of interactive features in non-JS mode.
- Requires a consistent and disciplined approach to development and testing to ensure adherence to the progressive enhancement strategy.
Comment on lines +39 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow the pro/con framing at the end feels out of place, but I don't know exactly why. Maybe because these aren't concrete consequences but rather feel like part of the discussion / context.

Since the pros are already mentioned there - maybe move the negative points up as known challenges and just remove the whole section here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to say, I like the conciseness of the pro and con arguments here. If someone agrees with you, I'm happy to do what you suggested though.