Tech Tip #7: Weigh your web page

We cut our home page from six point eight megabytes to one point seven.

Video created by explainapaper.com

The problem

Pages grow by accretion: a slider plugin here, a second copy of jQuery there, full-size images everywhere. Every visitor downloads all of it, on every first view.

The fix you can use today

  • Measure a first view: bytes and requests, with a real browser.
  • Remove scripts a page does not use and purge unused CSS.
  • Recompress images, serve WebP or AVIF, and lazy-load what is below the fold.

That is GreenCode's own website, measured before and after the rebuild.

Tools that help

  • Lighthouse: audits a page for total byte weight, unused JavaScript and CSS, image formats and offscreen images
  • WebPageTest: loads a real page and shows every request, its size and when it loaded
  • CO2.js (Green Web Foundation): an open-source library that turns bytes transferred into an estimate of CO2, using the Sustainable Web Design model

How GreenCode helps

GreenCode helps tackle this by practising it on greencode.ai: static pages, WebP images, scripts only where they are used and purged styles cut a first view of the home page from 80 requests to 33. More on this.

Tags

#web-performance#images#javascript#frontend

Sources

Transcript

We cut our home page from six point eight megabytes to one point seven. That is GreenCode's own website, measured before and after the rebuild. Web pages grow bit by bit. A slider plugin here, a second copy of a script there. And full-size images everywhere. Every visitor downloads all of it, on their first visit. Every byte uses energy in the data centre, the network and your phone. Here is the fix you can use today. First, weigh a first visit in a real browser: bytes and requests. Remove the scripts a page does not use. Cut out the styles nobody uses. Shrink your images, use modern formats, and load images further down only when needed. Find what to cut using tools like Lighthouse and WebPageTest. GreenCode helps tackle this by practising it on its own site. Our page went from eighty requests to thirty-three. The Green Web Foundation's library turns those bytes into a carbon estimate. We estimate about a fifth of a gram of carbon dioxide per view. That was GreenCode Tech Tip number seven. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #7
  • For Developers
  • Length 1:12
  • Category Web and front-end
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch