Reputation: 63
I'm working on my first GatsbyJS project (and hosted on Netlify) and over the past few weeks have noticed that everything is very speedy during development, but when built and hosted the pages are very slow to load (particularly the images).
This is a very simple marketing site (just 6 or so pages with a few images per page), so I figured I must be doing something wrong since Gatsby is said to be "blazing-fast", and that is definitely not my experience in prod. The landing page currently takes ~40sec to load, and is only a few images and a nav bar.
I'm loading images fairly simply per the docs, but is there some optimization step that I should also be doing? Or storing assets in a particular location for Gatsby to optimize?
Most recent build: https://musing-goldstine-2f7024.netlify.com/
Thanks for any info!
Upvotes: 3
Views: 2945
Reputation: 91
With Netlify you can now go to the site you wish to optimize, then: Site settings > Build & deploy > Post processing.
I turned them all on and they seem to work perfectly with my GatsbyJS site, including image optimization.
Upvotes: 6
Reputation: 270
The issue is that you are serving scaled images. A scaled image is an image that has been scaled to match the size that it is displayed.
For example, on this page:
This cityscape is resized in HTML or CSS from 3840x1200 to 1366x600. Serving a scaled image could save 5.0MiB (82% reduction).
Chrome Developer Tools Network Tab on this site
Another good site to analyze your page speed: https://gtmetrix.com/
To improve page load time:
Use a photo editor (Photoshop, GIMP, etc) and resize the photo dimensions down to the maximum display size.
After resize, compress images to improve page load time further.
Resources for compressing images:
Image Optimization Guidelines
Final step: Replace your unoptimized images with your newly optimized images. You should see a drastic improvement in page load time.
Upvotes: 3