A fast page isn't a luxury — for someone on a budget phone and a patchy 3G connection, it's the difference between using your site and giving up. Plenty of speed comes from a few HTML habits. You've already met some; here we pull the performance ones together.
1Load scripts without blocking
By default, when the browser hits a <script> tag it stops building the page to download and run it. A few scripts in the <head> can leave the user staring at a blank screen. Two attributes fix this:
| Attribute | What it does | Use for |
|---|---|---|
defer | Download in the background, run after the page is parsed (in order). | Most scripts — the safe default. |
async | Download in the background, run as soon as it arrives (any order). | Independent scripts like analytics. |
<script src="app.js" defer></script>
defer almost always. The page renders immediately and your script still runs once everything's ready.- A plain
<script>blocks page rendering while it downloads and runs. deferruns scripts after parsing, in order — the safe default for most scripts.asyncruns as soon as the script arrives, in any order — good for independent things like analytics.
2Lean images and no layout jumps
Images are usually the heaviest thing on a page, so the wins from the Images lesson are also your biggest performance wins:
loading="lazy"— off-screen images download only when the user scrolls near them. Huge on long, image-heavy pages.- Right-sized files — never send a 4000-pixel photo to display at 400 pixels. Resize and compress.
- Set
widthandheight— this reserves the correct space so the page doesn't jump as images load. That annoying shift where you go to tap something and the page lurches? This prevents it.
Lean markup, fewer requests
Every file the page loads is a round trip. Keep markup tidy, avoid loading the same library twice, and don't pull in a giant framework for one small effect. On a fast laptop you'd never notice; on a ₹6,000 phone on rural 3G, it's the whole experience.
loading="lazy"defers off-screen images — a big saving on image-heavy pages.- Send right-sized, compressed images; never a giant file scaled down in the browser.
- Set
widthandheightto reserve space and stop the page jumping as it loads. - Lean markup and fewer requests matter most on cheap phones and slow networks.
★ Practical: tune a page for speed
Write or adjust markup so that:
- A
<script>usesdeferso it doesn't block rendering. - Below-the-fold images use
loading="lazy". - Each
<img>haswidthandheightset. - Note one thing you could remove to cut a network request.
Ready to test yourself?
Take the short quiz. Score 60% or more to mark this lesson complete.
Start the quiz →💡 Log in to save your progress and earn the certificate.