-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[sharp & remark-images] Generating unused images? #3738
Comments
Closing this issue for now. Seems to be an edge case. |
This was referenced Sep 5, 2021
This was referenced Sep 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
when I first used
gatsby-plugin-sharp
respectivelygatsby-image
andgatsby-remark-images
I didn't pay much attention to the details of these packages and how they generate images.My personal site is still pretty small but I'm already generating 600 images and I first didn't understand why. Someone showed me these lines:
gatsby/packages/gatsby-plugin-sharp/src/index.js
Lines 427 to 434 in c147a08
I'm using the
sizes
queries forgatsby-image
andgatsby-remark-images
is using it automatically. It says:For a fluid container this perfectly makes sense.
Example:
You have a full-width hero image/header and define a
maxWidth: 2560
for the images (e.g. you know that most of your users use monitors smaller than that). People with bigger screens might see the header and therefore also2x
and3x
versions are fine.But here comes the problem:
What if the
maxWidth
is actually themax-width
of the container? It's absolutely common to have blogposts at width of ~ 800px to improve readability. You setmaxWidth
ingatsby-remark-images
to 800 and everything is fine? In my opinion not!If you're already using bigger images and/or want to reduce the amount of images that's a problem.
Example:
https://upbeat-edison-0598aa.netlify.com/marion-michele
I set the
maxWidth
ingatsby-remark-images
to 1600 (it also applies tosizes
query for a component) as the image will never be bigger than 1600px.But why don't you use
resolutions
? (which creates 1.5x, 2x ... versions of the image)Because I don't want to serve 1600px images to mobile users.
Here's what
gatsby-remark-images
generates:If I don't want to serve images for retina OR think that the maxWidth already is enough the last to images would be unnecessary.
Am I completely mistaken here with my assumptions?
I know: It's an edge case.
So my proposal would be:
Adding an option to exclude the generation of 1.5x, 2x etc. to minimize the amount of generated images.
The text was updated successfully, but these errors were encountered: