Tips・Publishing your work

Five things a beginner can do to speed up a slow site

A heavy site is almost always heavy because of images. Five fixes you can make with HTML and CSS alone — including loading="lazy" and width/height — plus how to measure with PageSpeed Insights.

A heavy site is heavy because of images, nine times out of ten. There are five things you can do with HTML and CSS alone. Start here.

1. Shrink your image files

The biggest win. A photo from your phone is 3–5MB; for the web, under 200KB looks fine.

  • Resize oversized images to the size you display them at (1600px wide covers most cases)
  • Run them through a compression tool
  • Convert photos to WebP for the same look at a smaller size
TipsMake images lighter to speed up your pageThe step-by-step for making images lighterTipsHow to convert images to WebPHow to convert to WebP

2. Add loading=“lazy” to images

Tells the browser not to load an image until it’s about to be seen. One attribute, real effect.

<img src="gallery1.jpg" alt="A long-tailed tit in the snow" loading="lazy">

The more images sit lower down the page, the more it helps.

3. Put width and height on images

They reserve space while the image loads. Without them, your text jumps the moment an image arrives.

<img src="shima.png" alt="A long-tailed tit" width="800" height="600">
img {
  width: 100%;
  height: auto;
}

The HTML numbers exist to convey the aspect ratio. With width: 100% and height: auto in CSS, your layout stays as designed.

4. Use fewer web fonts

Nice-looking fonts from Google Fonts load a file per style, and font files can run from hundreds of kilobytes into megabytes.

  • Stick to one or two families
  • Choose only the weights you use (400 and 700, say)
  • Consider web fonts for headings only, with system fonts for body text
TipsChange the face of your text with Google FontsLoading Google Fonts, and trimming what you load

5. Get the loading order right

CSS in <head>, JavaScript just before </body> (or with defer).

<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- content -->
  <script src="script.js" defer></script>
</body>

defer means “run this after the HTML is parsed.” Without it, loading JavaScript blocks the page from rendering.

Measuring: PageSpeed Insights

Don’t guess, measure. Enter a published URL and get a score and a list of improvements for mobile and desktop, free.

The PageSpeed Insights home page, with a field for entering a web page URL and an Analyze button
Enter a URL, wait half a minute, and you get a score plus a list of opportunities.

PageSpeed Insights

Of the jargon it produces, only two things matter early on.

MetricMeaningWhat fixes it
LCPHow long until the largest element appearsLighter images
CLSHow much the layout shifted while loadingwidth and height on images

Do them in this order

It looks like a lot, but the priority is clear.

  1. Lighten images — 80% of the effect
  2. loading=“lazy”, width and height — just attributes
  3. Fewer fonts — drop a family
  4. defer — one word

Work down that list and most sites end up fast enough.

Summary

  1. Slowness is mostly images; making them lighter helps most
  2. loading="lazy" only on off-screen images; width and height stop the jumping
  3. Measure with PageSpeed Insights and work down the opportunities it lists

A fast site quietly signals that it was built with care.

FAQ

How do I measure my website's loading speed?
Enter your published URL into Google's PageSpeed Insights. It gives you a score and a list of improvements for both mobile and desktop, for free.
Should I add loading="lazy" to every image?
Not to images visible in the first screen. Deferring those makes the page feel slower. It belongs on images you have to scroll to reach.
Won't width and height on an image break my layout?
Not if your CSS sets width:100% and height:auto. The HTML numbers exist to convey the aspect ratio, so space can be reserved while the image loads.