JavaScript Element contentvisibilityautostatechange Event

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
DOM event
Instance event

What You’ll Learn

The contentvisibilityautostatechange event fires on elements with content-visibility: auto when the browser starts or stops skipping their contents. Learn event.skipped, how to pause canvas or timers off-screen, addEventListener vs oncontentvisibilityautostatechange, and five try-it labs.

01

Kind

Instance event

02

Type

ContentVisibilityAutoStateChangeEvent

03

When

Skip / unskip contents

04

Handler

oncontentvisibilityautostatechange

05

Key field

event.skipped

06

Status

Baseline newly available

Introduction

Long pages often include heavy sections (charts, canvases, big lists) that sit far below the fold. CSS content-visibility: auto lets the browser skip layout and paint for those sections until they become relevant to the user—usually when they near the viewport.

contentvisibilityautostatechange is the JavaScript companion: when skipping starts or stops, your code can pause or resume expensive work and save CPU and battery.

💡
Beginner tip

Check event.skipped. If true, stop canvas loops / timers. If false, start them again. Do not use this to skip important accessibility / semantic DOM updates.

Understanding contentvisibilityautostatechange

An instance event that answers: “Did the browser just start or stop skipping this content-visibility: auto element’s contents?”

  • Requires content-visibility: auto on the element.
  • Fires when relevance changes and skipping starts or stops.
  • Event typeContentVisibilityAutoStateChangeEvent.
  • Key propertyskipped (true = rendering skipped).
  • Baseline Newly available on MDN (since September 2024).

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("contentvisibilityautostatechange", (event) => { });

oncontentvisibilityautostatechange = (event) => { };

Event type

A ContentVisibilityAutoStateChangeEvent.

Event properties

PropertyMeaning
skippedtrue if the user agent is skipping the element’s contents; otherwise false

CSS partner

JavaScript
.panel {
  content-visibility: auto;
  contain-intrinsic-size: 300px; /* optional size hint while skipped */
}

🔁 Skip / Resume Flow

  1. Element has content-visibility: auto.
  2. Browser decides contents are not relevant (for example far off-screen) and skips rendering.
  3. contentvisibilityautostatechange fires with event.skipped === true — pause heavy JS work.
  4. When the element becomes relevant again, the event fires with skipped === false — resume work.

Contents can still remain available to find-in-page, focus, and assistive technology even while skipped for painting—treat this as a performance signal, not a “delete the DOM” signal.

⚖️ vs IntersectionObserver

APIRole
content-visibility: auto + this eventBrowser skips layout/paint; you sync JS work via skipped
IntersectionObserverYou observe viewport entry yourself; browser does not auto-skip paint
TogetherUse this event when you already rely on content-visibility; fall back to IntersectionObserver on older browsers

⚡ Quick Reference

GoalCode / note
Listenel.addEventListener("contentvisibilityautostatechange", fn)
Handler propertyel.oncontentvisibilityautostatechange = fn
Enable CSSel.style.contentVisibility = "auto"
Is painting skipped?event.skipped
MDN statusBaseline Newly available (Sep 2024)

🔍 At a Glance

Four facts to remember about contentvisibilityautostatechange.

Event type
ContentVisibilityAutoStateChangeEvent

skipped flag

Needs CSS
content-visibility: auto

Required partner

Use for
pause / resume

Canvas, timers, workers

Baseline
2024

Newly available

Examples Gallery

Examples follow MDN Element: contentvisibilityautostatechange event. Scroll panels with content-visibility: auto in and out of view to see skipped flip.

📚 Getting Started

Listen for skip/unskip and read event.skipped (MDN style).

Example 1 — addEventListener (MDN canvas pattern)

MDN idea: pause canvas updates when contents are skipped.

JavaScript
const canvasElem = document.querySelector("canvas");

canvasElem.addEventListener("contentvisibilityautostatechange", stateChanged);
canvasElem.style.contentVisibility = "auto";

function stateChanged(event) {
  if (event.skipped) {
    stopCanvasUpdates(canvasElem);
  } else {
    startCanvasUpdates(canvasElem);
  }
}
Try It Yourself

How It Works

Set contentVisibility = "auto", then react to event.skipped. Without auto, the event will not drive this lifecycle.

Example 2 — oncontentvisibilityautostatechange

Same hook using the handler property.

JavaScript
const panel = document.getElementById("panel");

panel.oncontentvisibilityautostatechange = (event) => {
  console.log("skipped:", event.skipped);
};

panel.style.contentVisibility = "auto";
Try It Yourself

How It Works

Prefer addEventListener when you need multiple listeners or easy removal.

📈 Log, Canvas & Timer

Log state changes, pause drawing, and pause a counter.

Example 3 — Log skipped on scroll

A tall spacer helps you scroll the panel off-screen and back.

JavaScript
const panel = document.getElementById("panel");
const log = document.getElementById("log");

panel.addEventListener("contentvisibilityautostatechange", (event) => {
  log.textContent += "skipped=" + event.skipped + "\n";
});

panel.style.contentVisibility = "auto";
Try It Yourself

How It Works

Exact timing depends on the browser’s relevance heuristics. Scroll far enough for the panel to leave the near-viewport region.

Example 4 — Pause a simple canvas loop

Stop requestAnimationFrame while skipped.

JavaScript
const canvas = document.getElementById("c");
const ctx = canvas.getContext("2d");
const status = document.getElementById("status");
let raf = 0;
let t = 0;

function draw() {
  t += 0.05;
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  ctx.fillStyle = "#2563eb";
  ctx.beginPath();
  ctx.arc(80 + Math.sin(t) * 40, 40, 16, 0, Math.PI * 2);
  ctx.fill();
  raf = requestAnimationFrame(draw);
}

function start() {
  if (!raf) raf = requestAnimationFrame(draw);
  status.textContent = "Drawing…";
}

function stop() {
  cancelAnimationFrame(raf);
  raf = 0;
  status.textContent = "Paused (skipped)";
}

canvas.addEventListener("contentvisibilityautostatechange", (event) => {
  if (event.skipped) stop();
  else start();
});

canvas.style.contentVisibility = "auto";
start();
Try It Yourself

How It Works

When the browser skips the canvas, cancel the animation frame. Resume when skipped becomes false.

Example 5 — Pause an interval timer

Same idea for polling-style work.

JavaScript
const panel = document.getElementById("panel");
const out = document.getElementById("out");
let n = 0;
let id = null;

function start() {
  if (id) return;
  id = setInterval(() => {
    n += 1;
    out.textContent = "ticks: " + n + " (running)";
  }, 500);
}

function stop() {
  clearInterval(id);
  id = null;
  out.textContent = "ticks: " + n + " (paused)";
}

panel.addEventListener("contentvisibilityautostatechange", (event) => {
  if (event.skipped) stop();
  else start();
});

panel.style.contentVisibility = "auto";
start();
Try It Yourself

How It Works

Polling and fake “live” counters are great candidates to pause while contents are skipped.

🚀 Common Use Cases

  • Pausing requestAnimationFrame / canvas drawing when a chart scrolls away.
  • Stopping polling or WebSocket-driven UI updates for off-screen panels.
  • Reducing CPU on long article pages with many interactive widgets.
  • Pairing with contain-intrinsic-size for smoother scroll layout.
  • Progressive enhancement: ignore the event on older browsers and keep work running.

🔧 How It Works

1

Set content-visibility: auto

The element opts into automatic skip-when-not-relevant behavior.

CSS
2

Browser skips contents

Layout and paint work for the subtree can be deferred.

Skip
3

Event fires with skipped

Your handler reads event.skipped and pauses or resumes JS work.

Signal
4

Faster pages, cooler devices

Browser paint savings plus your paused timers = better performance.

📝 Notes

  • MDN: Baseline Newly available (since September 2024).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Listen on the element that has content-visibility: auto (direct listener recommended).
  • Do not skip significant semantic / a11y DOM updates when skipped is true.
  • Related learning: compositionupdate, contextmenu, addEventListener(), JavaScript hub.

Baseline Newly Available

contentvisibilityautostatechange is marked Baseline Newly available on MDN (since September 2024). Logos use the shared browser-image-sprite.png sprite from this project. Feature-detect and keep work running as a fallback on older browsers.

Baseline · Newly available

Element contentvisibilityautostatechange

Works across the latest desktop and mobile browsers with content-visibility: auto when skip/unskip state changes.

New Newly available
Google Chrome Supported · Modern Chromium
Supported
Mozilla Firefox Supported · Recent releases
Supported
Apple Safari Supported · Recent macOS & iOS
Supported
Microsoft Edge Supported · Chromium
Supported
Opera Supported · Modern versions
Supported
Internet Explorer No content-visibility / event
Unavailable
contentvisibilityautostatechange Baseline 2024

Bottom line: Use content-visibility: auto with this event to pause expensive JS when contents are skipped; resume when skipped becomes false.

Conclusion

contentvisibilityautostatechange is the “browser skipped or unskipped my contents” signal. Pair it with content-visibility: auto, read event.skipped, and pause heavy work while paint is skipped.

Continue with contextmenu, addEventListener(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer addEventListener("contentvisibilityautostatechange", ...)
  • Attach the listener to the content-visibility: auto element
  • Pause canvas / timers when event.skipped is true
  • Consider contain-intrinsic-size to reduce scroll jumps
  • Feature-detect and keep a no-op fallback

❌ Don’t

  • Expect the event without content-visibility: auto
  • Skip semantic / accessibility DOM updates when skipped
  • Assume older browsers fire the event
  • Rely only on bubbling from a distant parent
  • Overwrite oncontentvisibilityautostatechange if you need multiple listeners

Key Takeaways

Knowledge Unlocked

Five things to remember about contentvisibilityautostatechange

Browser skip/unskip signal—pause expensive work with event.skipped.

5
Core concepts
📄 02

skipped

true = paused paint

API
🎨 03

Pause canvas

MDN classic use

Pattern
♿️ 04

Keep semantics

a11y still matters

Caution
🎯 05

Baseline 2024

newly available

Compat

❓ Frequently Asked Questions

It fires on an element with content-visibility: auto when the browser starts or stops skipping that element's contents because relevance to the user changed (for example the section scrolled far off-screen).
No. MDN marks it as Baseline Newly available (since September 2024). It is not Deprecated, Experimental, or Non-standard.
A ContentVisibilityAutoStateChangeEvent. The key property is skipped: true when the user agent is skipping the element's rendering, false when it is not.
Set content-visibility: auto on the element (via stylesheet or element.style.contentVisibility = "auto"). Without auto, this event does not apply.
No. MDN notes contents stay semantically relevant (for example for assistive technology). Use the signal to pause expensive rendering such as canvas loops or timers — not to drop meaningful accessibility updates.
Attach the listener directly to the element that has content-visibility: auto. Some guidance recommends capture or a direct listener because bubbling is not always reliable across implementations.
Did you know?

MDN’s classic demo pairs this event with a <canvas>: stop drawing when skipped is true, start again when it is false. That keeps fancy visuals cheap when the canvas is far off-screen.

Next: contextmenu

Handle right-click and build custom context menus.

contextmenu →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful