Skip to content

Conversation

@shayneahchoon
Copy link
Contributor

@shayneahchoon shayneahchoon commented Nov 11, 2025

Resolves JIRA: https://bbc.atlassian.net/browse/WS-1400

Summary

This is part of a spike, the following changes automatically redirect users on low data speeds. This approach uses Helmet and vanilla javascript. Alternative approaches including using the Next router, and Belfrage/GTM/Fastly were considered, but we felt that this was the best approach going forward.

Code changes

  • Adds a Helmet script to redirect.

Developer Checklist

  • UX
    • UX Criteria met (visual UX & screenreader UX)
  • Accessibility
    • Accessibility Acceptance Criteria met
    • Accessibility swarm completed
    • Component Health updated
    • P1 accessibility bugs resolved
    • P2/P3 accessibility bugs planned (if not resolved)
  • Security
    • Security issues addressed
    • Threat Model updated
  • Documentation
    • Docs updated (runbook, READMEs)
  • Testing
    • Feature tested on relevant environments
  • Comms
    • Relevant parties notified of changes

Testing

  • Manual Testing required?
    • Local (Ready-For-Test, Local)
    • Test (Ready-For-Test, Test)
    • Preview (Ready-For-Test, Preview)
    • Live (Ready-For-Test, Live)
  • Manual Testing complete?
    • Local
    • Test
    • Preview
    • Live

Additional Testing Steps

  1. List the steps required to test this PR.

Useful Links

@shayneahchoon shayneahchoon marked this pull request as draft November 12, 2025 15:47
@amoore108
Copy link
Contributor

Thanks for addressing the comments!

| '2g'
| '3g'
| '4g'
| '5g'
Copy link
Contributor

Choose a reason for hiding this comment

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

Still not convinced we'll get 5g through as per the docs - https://developer.mozilla.org/en-US/docs/Glossary/Effective_connection_type (though I know that was there before)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, I put this one here because it partially clashed with the hook that Neon are working on. I don't want to make any changes in case it affects their work.


const allowList = ['/pidgin/articles/czrzwn80zjmo'];
if (
window?.navigator?.connection?.effectiveType &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Older browsers like Opera Mini don’t support optional chaining I don't think, so they might hit a SyntaxError before the redirect runs (with the redirectScript.toString() injected in the script tag on lines 30-34

Copy link
Contributor

Choose a reason for hiding this comment

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

@amoore108 any thoughts on this? ^

Copy link
Contributor

@amoore108 amoore108 Nov 21, 2025

Choose a reason for hiding this comment

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

The script should be transpiled down by the time its rendered in the browser. Worth checking locally that that is the case.

return (
<script>
{`
window.addEventListener('load', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we use https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event instead? The window load will happen after all HTML/JSON/CSS/images load so perhaps too long?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants