Home / Learn HTML / HTML Performance and Loading

HTML Performance and Loading

Faster pages keep visitors and rank better. A few HTML attributes do most of the work.

In shortLoad only what is needed: lazy load images, use defer on scripts, and give images a width and height.

Definition

Performance is how fast your page loads and reacts. Slow pages lose visitors and rank lower. The biggest wins in HTML are small images, lazy loading, defer on scripts and fewer requests.

Theory in plain words

Faster loadingCompress imagesdefer scriptsCache filesPage shows sooner
Faster loading

What it is

Performance is how fast a page loads and responds.

Why we use it

Slow pages lose visitors and search ranking.

How it works

Smaller files, lazy loading, caching and fewer blocking scripts make the browser show content sooner.

Where it is used

  • Landing pages
  • Shops
  • Mobile users on slow networks
Lazy load imagesTry it Yourself
Width and height stop page jumpingTry it Yourself
defer a scriptTry it Yourself
async a scriptTry it Yourself
Preload an important fileTry it Yourself
Preconnect to another siteTry it Yourself
Modern image formatsTry it Yourself

Browsers use the first format they know. AVIF and WebP are much smaller than JPG.

Lazy load iframesTry it Yourself
Priority hintTry it Yourself

Tell the browser the main image is most important.

Do not load unneeded videoTry it Yourself
Measure load timeTry it Yourself

Quick quiz

1. Which attribute delays script run until the page is parsed?

2. Which makes images load when near the screen?

3. Modern small image formats

Common questions

Which attribute delays script run until the page is parsed?

defer. defer keeps page fast.

Which makes images load when near the screen?

loading="lazy". Lazy loading saves data.

My notes
Ask a question about this lesson