Layout Shift: What Each Jump Costs

Layout Shift: What Each Jump Costs

So everybody says give the images width and height or the page will jump, we say it too, but how much it jumps, we didn't have a number, and on our laptop there is Chrome, so why not to write few silly pages, each with one jump inside, and let him count.

Our numbers are these. Image without sizes, arriving after 700 ms, 0.110. Image with width and height, 0. Banner pushed on top, 0.024. Same banner into a box which waited with min-height, 0. The 0.110 did scare us a bit, because it is one single picture and the good limit is 0.1, so with this one forgotten attribute the page is already in the red, and with ten of them, we don't want to know.

.ad-slot {
  min-height: 250px;
}

.video-embed {
  aspect-ratio: 16 / 9;
  width: 100%;
}

Transform moving we also tried, 120 pixels, score 0. The button surprised more, we really thought after a click you can move what you want, so we press, text comes in 100 ms, 0, fine, as we thought, but in the entry is written 0.023 with hadRecentInput, hm, then we make it 900 ms, press, and 0.023 sits in the score! So only half a second you have, if your API is behind this button then make the place for answer before.

.notice {
  transform: translateY(-100%);
  transition: transform 200ms ease-out;
}

.notice.is-open {
  transform: none;
}
new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    if (entry.hadRecentInput) continue;
    for (const source of entry.sources) {
      console.log(entry.value.toFixed(3), source.node,
        source.previousRect, source.currentRect);
    }
  }
}).observe({ type: 'layout-shift', buffered: true });

See also: tuning the fallback and slow LCP and INP.