Skip to content

Serve smaller images and replace GIF demos with video - #207

Open
bendichter wants to merge 6 commits into
mainfrom
image-optimization
Open

bendichter wants to merge 6 commits into
mainfrom
image-optimization

Conversation

@bendichter

Copy link
Copy Markdown
Contributor

Combines three PRs that cut image and media weight. The built site drops from 218 MB to 173 MB. Each one is a separate merge commit, so they can be reviewed one at a time.

  • Convert the hero background images to WebP (#194): the six section backgrounds go from 11.3 MB to 1.0 MB in total at the same pixel dimensions, and the median image weight of a page drops from 2.8 MB to 0.6 MB. This also fixes the News banners, which referenced newsPageBg.png while the file was named newspageBg.png and so returned 404 on nwb.org.
  • Serve resized WebP images and lazy-load them (#193): mounts static/images as assets/images and adds an img-src.html partial that returns a WebP scaled to the width of the slot it is shown in. Images below the fold are lazy-loaded.
  • Replace the animated GIF demos on tool pages with video (#195): six screen recordings go from 51 MB of GIF to 5.4 MB of H.264 MP4 in muted, looping, inline <video> elements. The DeepLabCut and SLEAP card images become animated WebP.

The combined branch builds with Hugo 0.152.2 and produces the same 165 pages as main. pr_link_check failed on #195, so it may fail here too.

This conflicts with the draft #205 in hugo.yaml and layouts/shortcodes/tool-grid.html. Whichever merges second will need a rebase.

Supersedes #193, #194 and #195.

🤖 Generated with Claude Code

bendichter and others added 6 commits October 9, 2026 13:10
Images are stored at their original size in static/images and were served that way, so the news cards on the home page loaded about 6 MB of banners for 300 px slots and the Team page loaded a 9.8 MB headshot. No image on the site was lazy-loaded.

static/images is now also mounted as assets/images, which lets templates run images through Hugo's image processing. A new partial, img-src.html, returns a WebP version of a PNG or JPEG, scaled down to the width the slot needs, and falls back to the original URL for anything it cannot improve (remote URLs, SVG, GIF, small files, or a WebP that would be larger). The 60 template images that take their source from front matter use it with a width chosen for each slot, and a render hook applies it to Markdown images. All of them except the banner at the top of event and news pages are lazy-loaded.

Two CSS selectors matched images by file name including the .png extension. They now match on the name without the extension so they keep applying to the converted files.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Most pages use aboutBg.png as the background of the title banner. It is a 2.6 MB PNG that sits under a gradient at 90% opacity, and it accounted for most of the image weight of a typical page. The six section backgrounds are now WebP files at the same pixel dimensions, 0.99 MB in total instead of 11.3 MB, and the templates and stylesheet point at the new files.

The News pages referenced newsPageBg.png, but the file was named newspageBg.png, so on the case-sensitive production host the image returned 404 and those banners showed only the gradient. The converted file is named to match the reference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Six tool pages embedded screen recordings as animated GIFs, which totalled 51 MB. The NWB Widgets page alone loaded a 22 MB GIF and the Suite2p page a 17 MB one. They are now H.264 MP4 files (5.4 MB in total) played with a muted, looping, inline video element, which behaves the same way as the GIF did. The Suite2p recording is scaled from 1920 to 1600 pixels wide and the others keep their size.

The DeepLabCut and SLEAP cards on the Community Tools page used the same GIFs as their card image. Those are now animated WebP files, since the card template takes an image.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nwborg ready!

Name Link
🔨 Latest commit ac11ab4
🔍 Latest deploy log https://app.netlify.com/projects/nwborg/deploys/6acbcade7741590008d23c95
😎 Deploy Preview https://deploy-preview-207--nwborg.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 project configuration.

@bendichter

Copy link
Copy Markdown
Contributor Author

Before and after

"Before" is the production site and "after" is this PR's Netlify deploy preview, both at 1440 px wide.

News banner: the background photo now loads

Before After
before after

The "before" here is from nwb.org. Netlify serves filenames case-insensitively, so the missing background only shows on the GitHub Pages site.

NWB Widgets demo: looks the same as a video (the two captures are at different frames)

Before After
before after

The demo goes from a 22 MB GIF to a 0.35 MB MP4.

Images downloaded on first load, without scrolling:

Page Before After
Home 13.5 MB 0.4 MB
Team 19.2 MB 0.5 MB
About NWB 3.2 MB 1.0 MB

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
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.

1 participant