Closed Karansidds closed 4 years ago
It's properly a fontawesome icons tree-shaking problem.
Add babel-plugin-transform-imports
plugin and try tree-shaking @fortawesome/free-solid-svg-icons"
.
See the example here.
It's properly a fontawesome icons tree-shaking problem. Add
babel-plugin-transform-imports
plugin and try tree-shaking@fortawesome/free-solid-svg-icons"
. See the example here.
I am not using @fortawesome/free-solid-svg-icons, I've just installed it. But, I'm not using it anywhere. I've to remove it.
I am not using @fortawesome/free-solid-svg-icons Then try using
webpack-bundle-analyzer
to find out the problem.
Thank you for opening this!
You're importing quite some stuff in your files. Material Design, FontAwesome icons, Bootstrap (already the CSS in your gatsby-browser.js is probably really heavy), Firebase.
I'd suggest cutting down on your CSS, throw out unused/unnecessary packages and anaylze your bundles with: https://github.com/JimmyBeldone/gatsby-plugin-webpack-bundle-analyser-v2
You're also having multiple styling libraries in your package.json (e.g. emotion, css) or heavy packages like lodash. Make sure to be cautious about them.
We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!
Thank you for opening this!
You're importing quite some stuff in your files. Material Design, FontAwesome icons, Bootstrap (already the CSS in your gatsby-browser.js is probably really heavy), Firebase.
I'd suggest cutting down on your CSS, throw out unused/unnecessary packages and anaylze your bundles with: https://github.com/JimmyBeldone/gatsby-plugin-webpack-bundle-analyser-v2
You're also having multiple styling libraries in your package.json (e.g. emotion, css) or heavy packages like lodash. Make sure to be cautious about them.
We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!
Yeah! I agree that there lots of external css libraries that are being installed. But, how would it affect the bundle if it's not being used in the project? And my main question is not being answered, how can I reduce the size of component--src-pages that is generated by Gatsby for every page in the src/pages directory? For some pages where there's just text and no other heavy libraries even those pages are more than 1MB. I've mentioned that in the beginning of the question with some images. Please take a look at it as it's important.
You're importing this into every page:
import "bootstrap/js/dist/dropdown"
import "bootstrap/dist/css/bootstrap.min.css"
import "mdbreact/dist/css/mdb.css"
import "@fortawesome/fontawesome-free/css/all.min.css"
import "slick-carousel/slick/slick.css"
import "slick-carousel/slick/slick-theme.css"
import "react-slidedown/lib/slidedown.css"
import "css-ripple-effect/dist/ripple.min.css"
You can use the bundle analyzer to see why the pages chunks are so heavy, for me this would be a guessing game :)
You're importing this into every page:
import "bootstrap/js/dist/dropdown" import "bootstrap/dist/css/bootstrap.min.css" import "mdbreact/dist/css/mdb.css" import "@fortawesome/fontawesome-free/css/all.min.css" import "slick-carousel/slick/slick.css" import "slick-carousel/slick/slick-theme.css" import "react-slidedown/lib/slidedown.css" import "css-ripple-effect/dist/ripple.min.css"
You can use the bundle analyzer to see why the pages chunks are so heavy, for me this would be a guessing game :)
I think this could help me. Can you just tell me how could I use babel-plugin-transform-imports
in my website considering you've taken a look at the libraries that I'm using? This would help me a lot.
I would like to open this issue as the problem is not solved. I removed all of the css files from the gatsby-browser.js files and the size still remains the same. Please open this issue!
I closed the issue as it's not a problem with Gatsby but your individual project. Using the bundle-analyzer should give you the correct information why your bundle is so big.
LekoArts is right. You'll face same problem no matter you're using next.js
, create-react-app
, webpack only
or Gatsby
.
You have to learn how to use bundle-analyzer for all of your projects.
I checked the bundle analyzer as well. There every page is less than 100 kb. But, in production mode the component-pages-index.js goes above 1MB. What can I do in such case?
LekoArts is right. You'll face same problem no matter you're using
next.js
,create-react-app
,webpack only
orGatsby
. You have to learn how to use bundle-analyzer for all of your projects.
How can I move out hard coded information into page-data.json or chunk into separate files page-data-state? this is because index bundle contains html which increases file size, parsing time, compilatio and executation for pages with the same dataset...logos, svgs, images, etc.
23047 Summary
So, I've created an e-commerce website using Gatsby and I've loved everything about Gatsby such as prefetching, performance, etc. But, when I test my site using Google Lighthouse, I get a very less score for performance. Taking a look at the issues of my website, time to first byte(TTFB) is more than 5 seconds. So, I compared my site to Gatsby's site and I saw a big difference in the size of the component--src-pages generated by Gatsby. The size of every page of Gatsby's blog was less than 100KB, but for my website it was more than 1MB for every page. Thus, the size of my website had exceeded 8MB. Due to this, mobiles with slow network and processing were unable to load my website in a matter of seconds as they had to download resources worth 8MB. Sometimes, it took minutes to load the website. And also, everytime I click on a link to another page it took 2 seconds to respond and then load the page. This is a serious issue to me as this is not a personal project and is used by a startup with more than 2k customers. How can I decrease the size of my website and also improve TTFB and other performance issues?
Relevant information
My Site
Gatsby Blog
Lighthouse Audit
Index.js
Environment (if relevant)
package.json
:gatsby-node.js
:gatsby-browser.js
:gatsby-ssr.js
: N/A