Gatsby: How to Test Javascript Disabled?

Created on 15 May 2019  路  5Comments  路  Source: gatsbyjs/gatsby

How can I test how Gatsby performs with Javascript disabled, in local development? In this comment, the suggestion is to disable the Javascript preference to ensure service workers are also disabled. This works in production, but does not work when running gatsby in dev mode.

Thanks for your help.

question or discussion

Most helpful comment

@cameronmcefee SSR is a build-time optimization, not a develop-time optimization.

In other words, we don't statically render to HTML at _develop time_ (and therefore serve an experience that doesn't require JS) because it's extra overhead and a slower experience that a user wouldn't generally need. If you want to test the non-JS experience, you can use:

gatsby build
gatsby serve

and open up localhost:9000.

Hope this helps! Going to close this as answered, but if we can help further please feel free to reply/re-open and we can take another look. Thanks!

All 5 comments

So this is all dependent on your web browser you are using.

Chrome

On Google's Web Fundamentals site, they have a page describing how to Turn off JS in Chrome's Dev Tools

Firefox

There's a Firefox extension convienently called Disable JavaScript

Safari

If you open the preferences menu, go to Security and you can uncheck the Enable JavaScript checkbox.

Screen Shot 2019-05-15 at 10 33 41 PM

Hope this solved your question

Unfortunately, no. I understand how to disable Javascript, and that works when our site is deployed. However, if I'm running the site locally and do this, this is all I see:

Screen Shot 2019-05-15 at 8 17 12 PM

The markup is just a noscript tag.

@cameronmcefee SSR is a build-time optimization, not a develop-time optimization.

In other words, we don't statically render to HTML at _develop time_ (and therefore serve an experience that doesn't require JS) because it's extra overhead and a slower experience that a user wouldn't generally need. If you want to test the non-JS experience, you can use:

gatsby build
gatsby serve

and open up localhost:9000.

Hope this helps! Going to close this as answered, but if we can help further please feel free to reply/re-open and we can take another look. Thanks!

Ah, that makes sense. I appreciate the explanation.

@DSchau - Your response was extremely helpful

gatsby build
gatsby serve

Worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Oppenheimer1 picture Oppenheimer1  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

signalwerk picture signalwerk  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

ferMartz picture ferMartz  路  3Comments