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

SVG optimizations #1745

Merged
merged 4 commits into from
Oct 17, 2024
Merged

SVG optimizations #1745

merged 4 commits into from
Oct 17, 2024

Conversation

fturmel
Copy link
Collaborator

@fturmel fturmel commented Oct 14, 2024

I noticed there was an svgo script buried in the code base. I rewrote it so we could optimize all SVGs instead of just the ones in src/images/characters. Also the newer version of svgo should produce better outputs, the previously minified images were generated with v2.8 and without the multi-pass flag.

We're generating so many static pages and the majority of the SVGs are inlined, so even small improvements here could have some significance.

`node node-scripts/minify-svgs.mjs` output:
src/images/tracks.svg
  🟢 -54.23%
     -1.87 kB
static/images/train.svg
  🟢 -4.36%
     -2.45 kB
static/images/nebula-button.svg
  🟢 -14.94%
     -0.97 kB
src/images/sun.svg
  🟢 -43.85%
     -1.24 kB
src/images/playbutton.svg
  🟢 -32.49%
     -0.14 kB
src/images/train.svg
  🟢 -4.36%
     -2.45 kB
src/images/processing-icon.svg
  🟢 -26.79%
     -0.10 kB
src/images/open.svg
  🟢 -20.78%
     -0.07 kB
src/images/p5js-icon.svg
  🟢 -59.33%
     -3.25 kB
src/images/play.svg
  🟢 -22.19%
     -0.08 kB
src/images/playbutton-filled.svg
  🟢 -20.37%
     -0.03 kB
src/images/node-icon.svg
  🟢 -0.68%
     -0.01 kB
src/images/clock.svg
  🟢 -49.53%
     -1.85 kB
src/images/cloud.svg
  🟢 -41.57%
     -0.20 kB
src/images/train_track.svg
  🟢 -67.77%
     -1.20 kB
src/images/new-logo.svg
  🟢 -16.33%
     -0.47 kB
src/images/characters/Zero_6.svg
  🟢 -14.01%
     -0.24 kB
src/images/characters/Zero_3.svg
  🟢 -7.83%
     -0.15 kB
src/images/logo.svg
  🟢 -37.89%
     -4.27 kB
src/images/characters/Zero_5.svg
  🟢 -4.15%
     -0.09 kB
src/images/characters/Zero_2.svg
  🟢 -7.47%
     -0.19 kB
src/images/characters/Zero_1.svg
  🟢 -3.87%
     -0.06 kB
src/images/characters/WheelstheMouse_3.svg
  🟡 0.27%
     0.01 kB
src/images/characters/Zero_4.svg
  🟢 -9.50%
     -0.18 kB
src/images/characters/WheelstheMouse_2.svg
  🟢 -4.08%
     -0.14 kB
src/images/characters/WheelstheMouse_1.svg
  🟡 1.77%
     0.04 kB
src/images/characters/Triangle_9.svg
  🟢 -17.78%
     -0.33 kB
src/images/characters/Triangle_7.svg
  🟢 -6.89%
     -0.17 kB
src/images/characters/Triangle_8.svg
  🟢 -10.71%
     -0.19 kB
src/images/characters/Triangle_6.svg
  🟢 -19.56%
     -0.65 kB
src/images/characters/Triangle_5.svg
  🟢 -5.70%
     -0.13 kB
src/images/characters/Triangle_4.svg
  🟡 1.91%
     0.04 kB
src/images/characters/Triangle_1.svg
  🟢 -7.27%
     -0.13 kB
src/images/characters/Triangle_3.svg
  🟢 -3.88%
     -0.17 kB
src/images/characters/Train_Icon.svg
  🟢 -14.14%
     -0.98 kB
src/images/characters/ThisDot_8.svg
  🟡 1.17%
     0.02 kB
src/images/characters/ThisDot_7.svg
  🟢 -7.37%
     -0.11 kB
src/images/characters/ThisDot_9.svg
  🟢 -16.00%
     -0.14 kB
src/images/characters/Triangle_2.svg
  🟢 -1.79%
     -0.05 kB
src/images/characters/TrainRainbow.svg
  🟢 -0.02%
     -0.00 kB
src/images/characters/ThisDot_6.svg
  🟢 -3.31%
     -0.05 kB
src/images/characters/ThisDot_5.svg
  🟢 -3.82%
     -0.05 kB
src/images/characters/ThisDot_2.svg
  🟢 -8.29%
     -0.12 kB
src/images/characters/ThisDot_1.svg
  🟢 -2.20%
     -0.04 kB
src/images/characters/ThisDot_4.svg
  🟢 -14.65%
     -0.17 kB
src/images/characters/Square_6.svg
  🟢 -9.95%
     -0.20 kB
src/images/characters/Square_4.svg
  🟢 -13.69%
     -0.25 kB
src/images/characters/Square_5.svg
  🟢 -18.08%
     -0.33 kB
src/images/characters/Square_3.svg
  🟢 -1.68%
     -0.07 kB
src/images/characters/Square_2.svg
  🟡 5.24%
     0.09 kB
src/images/characters/ThisDot_3.svg
  🟡 0.52%
     0.01 kB
src/images/characters/SquareBrackets_4.svg
  🟢 -14.06%
     -0.29 kB
src/images/characters/SquareBrackets_3.svg
  🟢 -12.44%
     -0.40 kB
src/images/characters/SquareBrackets_1.svg
  🟢 -7.29%
     -0.12 kB
src/images/characters/Square_1.svg
  🟡 3.66%
     0.09 kB
src/images/characters/SemiColon_hello.svg
  🟢 -27.61%
     -0.63 kB
src/images/characters/SemiColon_5.svg
  🟢 -4.32%
     -0.10 kB
src/images/characters/SquareBrackets_2.svg
  🟢 -9.41%
     -0.33 kB
src/images/characters/SemiColon_4.svg
  🟢 -11.63%
     -2.44 kB
src/images/characters/SemiColon_3.svg
  🟢 -16.60%
     -1.61 kB
src/images/characters/SemiColon_1.svg
  🟢 -3.76%
     -0.07 kB
src/images/characters/Rainbow_1.svg
  🟢 -7.85%
     -0.18 kB
src/images/characters/Rainbow_2.svg
  🟡 7.28%
     0.22 kB
src/images/characters/SemiColon_2.svg
  🟢 -3.17%
     -0.11 kB
src/images/characters/PiGuy_2.svg
  🟡 4.56%
     0.09 kB
src/images/characters/PiRainbow.svg
  🟢 -18.90%
     -0.24 kB
src/images/characters/RainbowCandy.svg
  🟢 -13.13%
     -13.58 kB
src/images/characters/PiGuy_1.svg
  🟡 4.74%
     0.14 kB
src/images/characters/Equals_7.svg
  🟢 -20.24%
     -0.21 kB
src/images/characters/Equals_4.svg
  🟢 -13.48%
     -0.17 kB
src/images/characters/Equals_6.svg
  🟢 -25.62%
     -0.24 kB
src/images/characters/Equals_5.svg
  🟢 -35.64%
     -0.34 kB
src/images/characters/Equals_3.svg
  🟢 -36.06%
     -0.28 kB
src/images/characters/Equals_2.svg
  🟢 -14.73%
     -0.18 kB
src/images/characters/CurlyBrackets_5.svg
  🟡 1.09%
     0.03 kB
src/images/characters/Equals_1.svg
  🟢 -30.54%
     -0.26 kB
src/images/characters/CurlyBrackets_4.svg
  🟡 2.93%
     0.08 kB
src/images/characters/CurlyBrackets_2.svg
  🟡 1.84%
     0.07 kB
src/images/characters/CurlyBrackets_3.svg
  🟡 0.47%
     0.01 kB
src/images/characters/ChooChooBot_2.svg
  🟢 -6.24%
     -0.40 kB
src/images/characters/CurlyBrackets_1.svg
  🟡 10.83%
     0.21 kB
src/images/characters/ChooChooBot_1.svg
  🟢 -10.06%
     -0.65 kB
src/images/characters/Gloria Pickle.svg
  🟢 -7.34%
     -0.54 kB
src/images/characters/Asterik_5.svg
  🟢 -14.02%
     -0.18 kB
src/images/characters/Asterik_3.svg
  🟢 -9.73%
     -0.15 kB
src/images/characters/Asterik_4.svg
  🟢 -19.01%
     -0.24 kB
src/images/characters/Asterik_2.svg
  🟢 -5.66%
     -0.10 kB
src/images/characters/AllAboard.svg
  🟢 -18.16%
     -11.93 kB
src/images/characters/Asterik_1.svg
  🟢 -10.17%
     -0.18 kB
src/images/characters/homepage-illustration.svg
  🟢 -0.78%
     -11.65 kB
src/images/characters/homepage.svg
  🟢 -0.68%
     -10.62 kB
Done! -83.31 kB size difference total

Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for codingtrain ready!

Name Link
🔨 Latest commit 9d953bd
🔍 Latest deploy log https://app.netlify.com/sites/codingtrain/deploys/670d39527d69bb00081d52f7
😎 Deploy Preview https://deploy-preview-1745--codingtrain.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@shiffman
Copy link
Member

This is amazing, thank you @fturmel!!

@shiffman shiffman merged commit 3715c12 into CodingTrain:main Oct 17, 2024
5 checks passed
@fturmel fturmel deleted the PR/svg-optimizations branch October 17, 2024 13:11
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