WS-2769 - Update Inline JS: NextJs - #14323
Open
louisearchibald wants to merge 21 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors inline JavaScript in the Next.js document to use extracted utility functions, aiming to align with Simorgh coding standards while keeping Opera Mini compatibility when function bodies are stringified and executed inline.
Changes:
- Extracts the “remove
no-jsclass” inline script intoremoveNoJsClassand invokes it viatoString()in_document. - Extracts client-side env var bootstrap logic into
setSimorghEnvVarsand invokes it inline with serialized env vars. - Updates
_document.page.tsxto use the new utilities.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ws-nextjs-app/pages/_document.page.tsx | Replaces inline JS snippets with stringified calls to extracted utility functions. |
| src/app/lib/utilities/setSimorghEnvVars/index.tsx | Adds a utility to set window.SIMORGH_ENV_VARS from server-provided values. |
| src/app/lib/utilities/removeNoJsClass/index.tsx | Adds a utility to remove the no-js class from the root element early in page load. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
hotinglok
reviewed
Aug 26, 2026
Contributor
There was a problem hiding this comment.
Does this need to be done here too?
https://github.com/bbc/simorgh/blob/latest/ws-nextjs-app/renderers/CanonicalRenderer.tsx#L147
Contributor
Author
There was a problem hiding this comment.
I've updated this now too, thanks for spotting. 🙏
…c/simorgh into WS-2769-update-inline-JS-nextJS
LilyL0u
approved these changes
Aug 28, 2026
…c/simorgh into WS-2769-update-inline-JS-nextJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves JIRA: WS-2769
Summary
Extracts inline JS code in the next app into separate functions to bring this inline with our coding standards.
Code changes
setSimorghEnvVarsand updates the existing inline script to use the extracted function.removeNoJsClassand updates the existing inline script to use the extracted function.Testing