/meta-wearables-webapp:ai-glasses-webapp-optimize-performance [production-url-or-build-directory]from meta-wearables-webapp
Measures and optimizes Meta Ray-Ban Display webapp performance using Chrome DevTools Protocol. Covers throttling profiles, bundle size reduction, critical CSS, and image downscaling for smart glasses.
Ships in meta-wearables-webapp. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Read references/playbook.md before changing application code. Use this skill
with ai-glasses-webapp-build and ai-glasses-webapp-ui; their viewport,
composition, focus, and UI Toolkit rules remain authoritative. Finish with
ai-glasses-webapp-test after measuring the optimized build.
The 600×600 viewport below is a repeatable measurement profile, not an instruction to hardcode application dimensions. Keep Toolkit applications responsive. Optimize application source and assets, never installed Toolkit packages or the bundled validator. Use only public package exports; component subpaths are allowed when the installed Toolkit manifest declares them. Report Toolkit network or bundle cost separately; do not hide it, but do not patch dependency code to remove it.
Everything runs against local Chrome over the Chrome DevTools Protocol. The profile lets a laptop rank changes without glasses. CPU throttling is relative to that host, not a device emulator or a prediction of device timing. Compare builds on the same host under the same conditions. The zero-dependency scripts require Node.js 22 or newer.
| Constraint | Value | What it means for you |
|---|---|---|
| Link | ~500 Kbps down | 1 KB ≈ 16 ms (62,500 B/s). A 300 KB payload is ~4.8 s of link time before anything runs |
| Latency | ~150 ms RTT | Every extra round trip costs about 150 ms |
| CPU | 12× CDP slowdown on the test host | Parse and hydrate can dominate; this is not a fixed hardware equivalence |
| Viewport | 600×600, DPR 1 | Small images; no need for 2× assets |
| Panel | 30 Hz | The frame budget is 33 ms, not 16 ms |
The single most useful number is 1 KB ≈ 16 ms. Most startup wins are byte-count wins, and you can estimate them before you write any code.
Measure the same optimized output that would ship, never a development/HMR server. From the app root, build once and leave the preview running in a separate terminal (use the framework's equivalent production server if needed):
npm run build
npm run preview -- --host 127.0.0.1 --port 5173 --strictPort
The scripts reject common development-server resources rather than presenting their module and HMR traffic as production evidence.
Create a unique browser profile for every session. The cleanup trap removes only that generated directory after Chrome exits. Run the setup and one launch command in the same Bash terminal:
PERF_PROFILE="$(mktemp -d "${TMPDIR:-/tmp}/ai-glasses-perf.XXXXXX")"
trap 'rm -rf -- "$PERF_PROFILE"' EXIT
# macOS — choose this launch command
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 \
--user-data-dir="$PERF_PROFILE"
# Linux — or choose this one
google-chrome --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 \
--user-data-dir="$PERF_PROFILE"
Close Chrome when finished so the trap cleans the profile. Never point these
tools at a daily-use browser profile. If an app cannot mount without media permission,
add --grant-media; the tools never grant those permissions by default and
reset them after the run.
On Windows PowerShell, use a unique directory and guaranteed cleanup too (adjust the Chrome path if needed):
$perfProfile = Join-Path ([IO.Path]::GetTempPath()) ("ai-glasses-perf-" + [guid]::NewGuid())
New-Item -ItemType Directory -Path $perfProfile | Out-Null
try {
& "$env:ProgramFiles\Google\Chrome\Application\chrome.exe" `
--remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 `
"--user-data-dir=$perfProfile"
} finally {
Remove-Item -LiteralPath $perfProfile -Recurse -Force
}
node <this-skill>/scripts/measure.mjs --url http://127.0.0.1:5173 \
--reps 10 --clear-storage \
--oracle "document.querySelector('[data-testid=primary-screen]')"
Replace the example selector with one unique to usable content in the app.
--clear-storage deletes all data for that origin and the HTTP cache in the
temporary profile so every repetition starts from the same state.
It prints one line — the median over N cold loads, plus the spread:
cold n=10 FCP 420 ms visible 262 ms (spread 12) HTTP wire 872 B reqs 2
visible is a DOM/predicate timestamp, not proof of a painted frame or a working
input handler. Its watcher can fire from a mutation observer before paint. Verify
that the intended content is visible, then perform a meaningful action and check
its result separately. A splash or inert button is not success. Record that action
check separately; these scripts do not measure TTFI or field INP.
Warm launch is a separate run, add --warm: it clears the explicitly
authorized throwaway profile, loads once to populate the cache and any service
worker, then measures the reload. Record both. Every later claim is a
comparison against them. --clear-storage is required because a cold or warm
claim without a declared starting cache state is not reproducible.
The tools require at least 10 runs for a result. --smoke --reps 2 is available
only to verify plumbing; never cite a smoke result as performance evidence.
Each trap below has produced a confident, wrong answer.
FCP can fire for a logo or splash text before useful content is ready. Optimizing that paint alone can improve the number without helping the user. Define a content oracle for the intended screen, then verify a meaningful action separately.
--oracle is interpolated into !!( ... ), so it must be a single expression. Anything
containing statements has to be an IIFE, or it is a syntax error and the run
reports NEVER and exits nonzero:
// Bad: true for an empty shell, and for the browser's own error page
document.querySelector('#root').children.length > 0
// Good: names content only your app can produce
(() => {
const t = document.body.innerText || '';
return /Tuner/.test(t) && /E\s*A\s*D\s*G\s*B\s*E/.test(t)
&& document.querySelectorAll('button').length >= 3;
})()
Without one, a network error page scores well, because it has DOM and it paints fast.
If you show a splash or loading overlay, the content underneath is in the DOM — and
innerText already contains it — while the user still sees the splash. An oracle that
only checks the DOM is blind to anything that changes how long the overlay stays up.
Measured on a real app: a change that shortened the splash hold scored +20 ms (noise) on a DOM-presence oracle and −609 ms on an oracle that also required the overlay to be gone. Same change, same build; one oracle simply could not see it.
So your oracle must also assert the overlay is gone:
(() => {
const t = document.body.innerText || '';
const contentPresent = /Tuner/.test(t);
const splash = document.querySelector('.splash');
const covered = !!splash && getComputedStyle(splash).opacity !== '0';
return contentPresent && !covered;
})()
A cold load says nothing about the second launch, which is the common case for an app someone
uses daily. Measure both. measure.mjs --warm loads once to populate, then measures the
reload.
The page timestamps the first observation that the oracle passes with performance.now().
Machine noise remains, and three runs cannot resolve a small effect.
node <this-skill>/scripts/ab.mjs --a ./before --b ./after --reps 10 --clear-storage --oracle "document.querySelector('[data-testid=primary-screen]')" alternates
A,B,A,B… in one session and reports the paired difference.Ranked by what actually paid off, measured. Each line links to the detail, the code and the
numbers in references/playbook.md — read that before doing any of them.
| # | Change | Measured |
|---|---|---|
| 1 | Paint from the HTML, not from your bundle. Inline the first frame and critical CSS; make stylesheets non-blocking. Find the critical set with critical-css.mjs rather than guessing | first paint 11,208 → 440 ms |
| 2 | Stop shipping the same bytes twice. Fonts inlined as base64 and served as files is the usual one | −518 KB, −5,326 ms |
| 3 | Tree-shake app code and use declared component subpaths. Toolkit manifests stay immutable; change sideEffects only in app-owned packages | −72 KB, −1,754 ms |
| 4 | Downscale images to the smallest safe rendered size, then WebP at q75-80. The audit preserves object-fit crop needs and treats ambiguous backgrounds as unmeasured | up to −583 KB on one asset in testing |
| 5 | Declare the module graph with modulepreload so it is not discovered a hop at a time | −312 ms |
| 6 | Drop third-party font CDNs. Costs bytes, a connection, and breaks offline | −30 KB net |
| 7 | Ship WOFF2, three weights, subset to the characters you render | −23 KB |
| 8 | Count a splash hold from when the splash appeared, not from when your framework mounted | −609 ms |
| 9 | Respect the 30 Hz panel. 33 ms frame budget; stop requestAnimationFrame loops on hidden screens | — |
references/playbook.md also covers the smaller wins — font-display: swap, keeping
<head> free of render-blocking work, removing stale preconnect hints, and why more
parallel requests do not add throughput on this link.
--clear-storageai-glasses-webapp-build — application architecture, data, and offline behaviorai-glasses-webapp-ui — responsive Toolkit composition and public importsai-glasses-webapp-test — the final deterministic correctness and release gateai-glasses-webapp-publish — production deployment after both gates passWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub meta/meta-wearables-webapp --plugin meta-wearables-webapp7 skills in this plugin
/ai-glasses-webapp-buildCreate, redesign, or extend a web app for Meta Ray-Ban Display glasses. Use for application architecture, screens, routes, state, API-backed UI, persistence, offline behavior, or any product change; pair with ai-glasses-webapp-ui for toolkit setup and component composition. A complete initial app build includes a running local production preview and its URL./ai-glasses-webapp-deviceAdd Meta Ray-Ban Display glasses-specific sensors and input behavior: motion, orientation, compass, step detection, geolocation, neural-band activation/drag, D-pad game controls, or handwriting/voice text composition./ai-glasses-webapp-publishValidate and publish a finished Meta Ray-Ban Display glasses web app directly to Vercel production, confirm anonymous HTTPS access, and generate the Meta AI add-to-glasses QR code. No staging or passcode flow./ai-glasses-webapp-testRun the complete deterministic quality gate for a Meta Ray-Ban Display glasses web app: package/UI-toolkit checks, typecheck, production build, responsive viewport containment, local performance smoke checks, Playwright interaction, accessibility, sensors, and screenshots./ai-glasses-webapp-uiInstall and use UI Toolkit for Meta Ray-Ban Display in React web apps. Use whenever creating or changing glasses UI, selecting toolkit components, scaffolding a new app, or migrating custom UI. The toolkit is required by default unless the user explicitly opts out./ai-glasses-webapp-webmcpMake an existing Meta Ray-Ban Display web app controllable by the on-device assistant. Use when the wearer should operate the app by speaking to Meta AI, when the assistant should read or change app state, or for WebMCP, model context, tool registration, or hands-free control.Other plugins' skills for the same job