Skip to content

chore: optimize down the public/ dir png files - #2490

Open
jonchurch wants to merge 1 commit into
expressjs:mainfrom
jonchurch:jonchurch/optimize-png-in-place
Open

chore: optimize down the public/ dir png files#2490
jonchurch wants to merge 1 commit into
expressjs:mainfrom
jonchurch:jonchurch/optimize-png-in-place

Conversation

@jonchurch

Copy link
Copy Markdown
Member

Problem

When looking at our cloudflare analytics today it called out a few images as offenders in our LCP. Our LCP is generally quite "good" with 70% of all requests under 2.5 seconds. But these images were called out as potential offenders, Im thinking its their weight

Slimming down their weight should help pageload times where these images appear.

My plan is to watch the LCP stats over the next few weeks to measure how much of an impact this change had. Specifically for the /5x/guide/writing-middleware/ page bc that was cited as the worst in a couple langs like Japanese.

Solution

This PR optimizes all our pngs in the public/ dir in place.

File Before After Reduction
public/apple-touch-icon.png 3,557 B 978 B 72.5%
public/images/blog/redesign/before-after.png 435,879 B 140,677 B 67.7%
public/images/blog/redesign/brand-values.png 92,724 B 36,181 B 61.0%
public/images/blog/redesign/logo-favicon.png 47,064 B 16,418 B 65.1%
public/images/blog/redesign/vision-mission.png 82,218 B 31,845 B 61.3%
public/images/clustering.png 6,254 B 3,696 B 40.9%
public/images/express-mw.png 119,397 B 36,423 B 69.5%
Total 787,093 B 266,218 B 66.2%

I ran all the pngs in the public dir through pngquant

find public -name '*.png' -exec pngquant --quality 80-98 --skip-if-larger --strip --force --ext .png {} \;

in order to "quantize" the pngs. these are simple diagrams/logos mostly so they are pretty well suited to pngquant optimization.

The --quality 80-98 makes pngquant refuse to save any image that would fall below that quality floor. And I spot checked all the images manually against their previous versions and could see no difference.

context

Background on this is that anything in our public dir is not part of the astro build pipeline, so the images will not be optimized into webp like things in our src dir. This PR's in place optimization lets us see how/if our web vital stats are impacted by optimizing these images, without having to update any content pages to point to either new images (swapping png for webp for example) or a new image location.

We can eventually move images into the src dir if we wish for anything added in the future to be optimized via the build process, so we dont have to do maual optimizations like this or think much about it in the future (there are also some drawbacks to letting astro handle the images for us, like it lazy loading images in markdown content etc which can actually hurt LCP).

## Problem

When looking at our cloudflare analytics today it called out a few
images as offenders in our LCP. Our LCP is generally quite "good" with
70% of all requests under 2.5 seconds. But these images were called out
as potential offenders, Im thinking its their weight

Slimming down their weight should help pageload times where these images
appear.

My plan is to watch the LCP stats over the next few weeks to measure
how much of an impact this change had. Specifically for the
/5x/guide/writing-middleware/ page bc that was cited as the worst in a
couple langs like Japanese.

## Solution

This PR optimizes all our pngs in the public/ dir in place.

| File | Before | After | Reduction |
|---|---:|---:|---:|
| `public/apple-touch-icon.png` | 3,557 B | 978 B | 72.5% |
| `public/images/blog/redesign/before-after.png` | 435,879 B | 140,677 B | 67.7% |
| `public/images/blog/redesign/brand-values.png` | 92,724 B | 36,181 B | 61.0% |
| `public/images/blog/redesign/logo-favicon.png` | 47,064 B | 16,418 B | 65.1% |
| `public/images/blog/redesign/vision-mission.png` | 82,218 B | 31,845 B | 61.3% |
| `public/images/clustering.png` | 6,254 B | 3,696 B | 40.9% |
| `public/images/express-mw.png` | 119,397 B | 36,423 B | 69.5% |
| **Total** | **787,093 B** | **266,218 B** | **66.2%** |

I ran all the pngs in the public dir through [pngquant](https://pngquant.org/)

```sh
find public -name '*.png' -exec pngquant --quality 80-98 --skip-if-larger --strip --force --ext .png {} \;
```
in order to "quantize" the pngs. these are simple diagrams/logos mostly
so they are pretty well suited to pngquant optimization.

The `--quality 80-98` makes pngquant refuse to save any image that would
fall below that quality floor. And I spot checked all the images
manually against their previous versions and could see no difference.

### context

Background on this is that anything in our public dir is not part of the
astro build pipeline, so the images will not be optimized into webp like
things in our src dir. This PR's in place optimization lets us see how/if our
web vital stats are impacted by optimizing these images, without having
to update any content pages to point to either new images (swapping png
for webp for example) or a new image location.

We can eventually move images into the src dir if we wish for anything
added in the future to be optimized via the build process, so we dont
have to do maual optimizations like this or think much about it in the
future (there are also some drawbacks to letting astro handle the images for
us, like it lazy loading images in markdown content etc which can
actually hurt LCP).
@jonchurch
jonchurch requested a review from a team as a code owner August 26, 2026 00:55
@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 763859a
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6a8e399884f13100084f9fd2
😎 Deploy Preview https://deploy-preview-2490--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bjohansebas bjohansebas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgmt, free to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants