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

Disable javascript #11680

Closed
yepes opened this issue Feb 10, 2019 · 9 comments
Closed

Disable javascript #11680

yepes opened this issue Feb 10, 2019 · 9 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@yepes
Copy link

yepes commented Feb 10, 2019

Hi everyone

I have created a single page webpage that doesn't provide any user interaction.
I have all the content in markdown files, and I use gatsby to generate a static, just one page website.
All I need is the html content and the images. Everything is working, but gatsby is adding some javascript files that i wont never use.

How can I avoid that?

@mherchel
Copy link

Gatsby is a static site generator based on React. One of it's purposes is to prefetch additional pages.

I honestly think that a one-page non-JS site is outside of Gatsby's use-case. For a one-pager, why not use static HTML?

@yepes
Copy link
Author

yepes commented Feb 10, 2019

Yep, maybe that's right. I just discovered gatsby the other day and had to do something simple and test it. Just wondering if that would be possible.

I know about other "older" static sites generator, I just wanted to try something new

@pieh
Copy link
Contributor

pieh commented Feb 11, 2019

We don't support this out of the box, but if you feel advanteruous I think this would doable using onPreRenderHTML hook in gatsby-ssr.js - especially for js bundles you would want to use getHeadComponents and filter out js ones (or just all script tags, and use replaceHeadComponents with filtered list of components. Might need to check "pre-body components" and "post-body components"

@KyleAMathews
Copy link
Contributor

People build tons of 1 pager sites with Gatsby. Just like larger sites, it's far more productive to use Gatsby with ready-designed development environment and plugins, and optimized production builds vs doing it by hand. Also one page sites rarely stay one page. Also it's rare too for sites to not eventually need JavaScript.

Back to the subject of removing the js script tags. It'd be nice if there was a plugin which followed the algorithm @pieh described. It could work for all pages or just specified pages.

@LekoArts
Copy link
Contributor

I honestly think that a one-page non-JS site is outside of Gatsby's use-case. For a one-pager, why not use static HTML?

One-Pager are a perfect usecase. I saw so many websites with 30MB of images loading... You get that optimizations for free then

@yepes
Copy link
Author

yepes commented Feb 11, 2019

@pieh thanks, i will take a look at it and try to do something this week.

@KyleAMathews yeah, that would be awesome. But i'm getting a grasp of React and this is my first project using gatsby, so I don't think I can do that yet

@pieh pieh added the type: question or discussion Issue discussing or asking a question about Gatsby label Feb 11, 2019
@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 4, 2019
@gatsbot
Copy link

gatsbot bot commented Mar 4, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot
Copy link

gatsbot bot commented Mar 15, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Mar 15, 2019
@itmayziii
Copy link

I wrote a Gatsby plugin that removes Gatsby generated javascript for those that find this issue in the future

https://www.npmjs.com/package/gatsby-plugin-no-javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants