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?
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?
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
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"
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.
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
@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
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鈥檚 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! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 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!
I wrote a Gatsby plugin that removes Gatsby generated javascript for those that find this issue in the future
Most helpful comment
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.