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

feat(gatsby-plugin-offline): "Magic" JS detection to make sites function correctly when JS is disabled retroactively #17590

Merged
merged 13 commits into from
Sep 19, 2019
Merged

Conversation

vtenfys
Copy link
Contributor

@vtenfys vtenfys commented Sep 12, 2019

Description

gatsby-plugin-offline's service worker (which still runs if JavaScript has been disabled retroactively) can now detect via a conditional network request whether or not JavaScript has been disabled in the browser, and serve a page from the network if this is the case.

Related Issues

Closes #17386

@vtenfys vtenfys requested a review from a team as a code owner September 12, 2019 15:46
@vtenfys vtenfys changed the title feat(gatsby-plugin-offline): "Magic" JS detection to make sites function correctly when JS is disabled later feat(gatsby-plugin-offline): "Magic" JS detection to make sites function correctly when JS is disabled retroactively Sep 13, 2019
@KyleAMathews
Copy link
Contributor

Nice "magic" :-D

@@ -15,9 +15,6 @@ export default function HTML(props) {
</head>
<body {...props.bodyAttributes}>
{props.preBodyComponents}
<noscript key="noscript" id="gatsby-noscript">
This app works best with JavaScript enabled.
</noscript>
Copy link
Contributor

Choose a reason for hiding this comment

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

should this change be part of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also for reference - this is PR that added this initially #10945 so worth checking reasoning and see if we don't break that (or at least it's conscious decision)

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@vtenfys vtenfys added bot: merge on green Gatsbot will merge these PRs automatically when all tests passes and removed status: WIP labels Sep 19, 2019
@gatsbybot gatsbybot merged commit e451815 into gatsbyjs:master Sep 19, 2019
LOLdevelopr pushed a commit to LOLdevelopr/gatsby-1 that referenced this pull request Sep 21, 2019
…ion correctly when JS is disabled retroactively (gatsbyjs#17590)

* Set path resources on route update (for initial page load)

* begin "magic"

* refactor + fix always re-enabling

* implement SW API route + only set head components for offline shell + misc

* update snapshots

* change messageapi back to a "normal" object

* add comment re: syntax

* rename back to original casing

* add back noscript warning in default-html

* restore snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page HTML isn't served when visiting a site with offline plugin, then disabling JS
4 participants