Skip to content
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

chore: use pngquant to optimize PNG images #583

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

dsanders11
Copy link
Member

@dsanders11 dsanders11 commented Jun 21, 2024

Uses imagemin-pngquant to optimize PNG images at build time.

Significantly reduces the size of images used on the home page, shrinking transferred size from 4.4 MB to 1.2 MB.

It's technically lossy optimization, but I don't think anyone can tell the difference between this and this unless you've got Superman eyes.

Before:
Before

After:
After

@MarshallOfSound MarshallOfSound temporarily deployed to electronjsorg-new-pr-583 June 21, 2024 02:32 Inactive
@dsanders11 dsanders11 marked this pull request as ready for review June 21, 2024 02:38
@dsanders11 dsanders11 requested a review from a team as a code owner June 21, 2024 02:38
@dsanders11 dsanders11 marked this pull request as draft June 21, 2024 02:39
@dsanders11 dsanders11 requested a review from erickzhao June 21, 2024 02:44
@dsanders11 dsanders11 marked this pull request as ready for review June 21, 2024 02:44
Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

Unless there's a compelling reason to use a lossy compressor like pngquant, can we use one of the several lossless ones instead?

zopflipng, optipng, advpng, and pngcrush are all lossless options that have npm wrappers.

This script is overkill for electron/website but does show invocation recipes for trying to maximize lossless compression from these four tools

@dsanders11
Copy link
Member Author

The compelling reason is the significant reduction in size for imperceptible visual change.

I briefly tied a lossless optimizer on one of the larger files as a test and it was something like a 15% reduction, compared to 75% with pngquant.

Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

Great idea. LGTM once @BlackHole1's comment is addressed. :)

@MarshallOfSound MarshallOfSound temporarily deployed to electronjsorg-new-pr-583 June 21, 2024 19:34 Inactive
@dsanders11
Copy link
Member Author

Had an offline discussion with @ckerr regarding his comment, and moving ahead with taking the easy win here and we can follow up with other improvements in the future, such as committing losslessly optimized versions of the files to begin with. 👍

@dsanders11 dsanders11 merged commit b632bcc into main Jun 21, 2024
3 checks passed
@dsanders11 dsanders11 deleted the chore/pngquant branch June 21, 2024 20:12
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.

5 participants