Skip to main content brightness_auto motion_photos_off palette download more_vert
toc

Debugging

The shared plumbing of the components (motion waits, overflow measure passes, and scroll steps) can record performance marks.

The shared plumbing of the components (motion waits, overflow measure passes, and scroll steps) can record performance marks. They show up in the Chrome DevTools Performance panel as a custom track named md-gb, in the group Material. The marks are off by default.

The flag is read once, on first use, so set it before you interact with the components. Use any one of these:

  • Add ?md-gb-perf to the page address and load it.
  • Set the flag in the console, then reload. Any value turns the marks on, even 0. Remove the key to turn them off (the first sample below).
  • Set globalThis.MD_GB_DEBUG_PERF = true before any component runs (the second sample below).
HTMLJS
<md-gb-button id="on" color="tonal">Turn on</md-gb-button>
<md-gb-button id="off" color="tonal">Turn off</md-gb-button>
<output id="state" aria-live="polite"></output>
HTMLJS
<md-gb-button id="read" color="tonal">Read measures</md-gb-button>
<output id="measures" aria-live="polite"></output>

Open the Performance panel, start a recording, use the component, and stop it. Look for the md-gb track. Each span is also a performance.measure() entry:

HTMLJS
<md-gb-button id="list" color="tonal">List measures</md-gb-button>
<output id="names" aria-live="polite"></output>

When the flag is off, each call costs one boolean check and allocates nothing.

Install Material Web 3.0

Your browser did not offer to install the docs as an app. Install them from the browser instead:

Close
Send feedback
Bug Documentation Idea

Opens a new GitHub issue for material-components/material-web in a new tab, with this filled in.

Cancel Open issue