5

Is it possible to use Gatsby to generate static sites that can be viewed with Javascript disabled in the browser?

I heard that Gatsby sites could be accessed in this way but I've tried various Gatsby starters including gatsby-starter-default and gatsby-advanced-starter and all of them will only show the index page when Javascript is disabled. Link clicks return white screens.

I'm just looking for some graceful degradation here - I only need the basic pages and images to render, nothing more.

user47227
  • 165
  • 4

1 Answers1

1

Gatsby is generating critical portions of the app that are shown on page load and then "hydrates" the page with React, meaning that it first shows critical HTML and CSS and only after that load dynamic parts of the site. So if you use some additional react components which could not be prerendered they will not work but the site as a whole should work.

If you are using service workers and disabled JS from devtools than it could be a cache issue. Try to disable javascript from the browser preferences and run the website from the incognito window without devtools open. GatsbyJS based website should work.

But, your website will be faster and use less data with PWA and service workers enabled, which do need javascript.

Saša Šijak
  • 8,717
  • 5
  • 47
  • 82
  • 1
    Tried disabling Javascript from browser preferences and running incognito, as you suggested, and still doesn't work. I just get 'This app works best with JavaScript enabled.'. This is with a fresh install of the latest Gatsby. I'll investigate their docs and see if there's a way to get the page to render without JS. – Jonathan Oct 12 '19 at 09:18
  • Have a look at https://github.com/gatsbyjs/gatsby/issues/9626#issuecomment-435605109 – nathan Dec 03 '19 at 00:52