<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="https://amandavilela.me/">
    <title>Amanda Vilela | Web Performance &amp; Accessibility Insights</title>
    <subtitle>Technical writing on frontend performance, accessibility, Core Web Vitals, and scalable frontend.</subtitle>
    <link href="https://amandavilela.me/feed.xml" rel="self" type="application/atom+xml" />
    <link href="https://amandavilela.me/blog/" rel="alternate" type="text/html" />
    <id>https://amandavilela.me/blog/</id>
    <updated>2026-11-24T00:00:00.000Z</updated>
    <author>
        <name>Amanda Vilela</name>
        <uri>https://amandavilela.me/</uri>
    </author>
    <entry>
        <title>Building a Healthy AI Ecosystem on an Engineering Team</title>
        <link href="https://amandavilela.me/blog/ai-adoption-maturity-model/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/ai-adoption-maturity-model/</id>
        <published>2026-11-24T00:00:00.000Z</published>
        <updated>2026-11-24T00:00:00.000Z</updated>
        <summary>How to build a healthy AI ecosystem on an engineering team: a four-rung maturity model covering governance, guardrails, code review, and developer growth.</summary>
        <category term="ai" />
        <content type="html" xml:base="https://amandavilela.me/blog/ai-adoption-maturity-model/">&lt;p&gt;Are you an engineering leader who feels like you can&#39;t keep up with AI tools? Buying everyone a Claude or Cursor plan is just the start. A healthy AI ecosystem is built on review and guardrails, not on the tools you pick.&lt;/p&gt;
&lt;p&gt;AI amplifies development speed, but engineering teams need more than code velocity: shared standards, structured ideation and architecture workflows, reliable reviews, and trustworthy outputs.&lt;/p&gt;
&lt;p&gt;In most cases where teams feel they aren&#39;t getting the best out of AI, it&#39;s because people worry more about tools than about understanding where their AI usage sits, what the challenges are, and what it takes to reach the next level.&lt;/p&gt;
&lt;nav aria-labelledby=&quot;toc-title&quot; class=&quot;table-of-contents&quot;&gt;
    &lt;h2 id=&quot;toc-title&quot;&gt;Table of Contents&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;a href=&quot;#the-ladder&quot;&gt;The ladder&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#from-experimenting-to-adopting&quot;&gt;Rung 1 to 2: From experimenting to adopting&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#rung-2-give-your-tools-your-context&quot;&gt;Rung 2: Give your tools your context&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#rung-3-guarding&quot;&gt;Rung 3: Guarding&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#rung-4-growing&quot;&gt;Rung 4: Growing&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#knowing-where-you-stand&quot;&gt;Knowing where you stand&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#reaching-the-top-is-a-new-beginning&quot;&gt;Reaching the top is a new beginning&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
&lt;h2&gt;&lt;a href=&quot;#the-ladder&quot; id=&quot;the-ladder&quot;&gt;The ladder&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Teams don&#39;t level up by buying better software, but by maturing how they review code and mentor developers. Maturity models are an old idea, so here&#39;s one I aimed at AI on an engineering team:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Experimenting&lt;/strong&gt;: Individuals independently paste content into AI tools without shared norms or visibility.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Adopting&lt;/strong&gt;: The organization buys enterprise seats, but review processes and standards remain unchanged.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Guarding&lt;/strong&gt;:  Automated checks catch the recurring failure modes AI generates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Growing&lt;/strong&gt;: Code reviews and professional growth are deliberate; AI accelerates developers who understand their output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The rest of this post breaks down each rung: what it looks like, its defining failure mode, and how to reach the next rung.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#from-experimenting-to-adopting&quot; id=&quot;from-experimenting-to-adopting&quot;&gt;Rung 1 to 2: From experimenting to adopting&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What it looks like&lt;/strong&gt;: People are already using AI invisibly, pasting snippets into personal accounts without shared rules.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The defining failure&lt;/strong&gt;: You cannot manage or secure what you cannot see. Without clear team-wide AI policies, proprietary business data will inevitably leak into personal AI accounts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How you climb&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Governance first&lt;/strong&gt;: Ensure the entire team adheres to consistent standards, retaining organizational knowledge without compromising security.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pick one tool per job&lt;/strong&gt;: Standardize on a single primary tool for each task: code generation, review, testing, documentation, or debugging. Using multiple overlapping tools creates decision friction; establish an integration strategy to avoid a disorganized whack-a-mole approach.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Close the data gap&lt;/strong&gt;: Work with security and compliance teams to ensure model training excludes proprietary business logic and sensitive data. Enterprise plans typically offer data opt-outs; maintain a clear matrix of repository access and data residency guarantees for every tool.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;a href=&quot;#rung-2-give-your-tools-your-context&quot; id=&quot;rung-2-give-your-tools-your-context&quot;&gt;Rung 2: Give your tools your context&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What it looks like&lt;/strong&gt;: Seats are provisioned, but the tools lack context regarding your specific codebase and team conventions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The defining failure&lt;/strong&gt;: Tooling has evolved, but daily workflows haven&#39;t changed. A gap the next rung addresses.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How you climb&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: Strong documentation forms the backbone of AI integration. A clear knowledge base of your codebase and business rules enhances automated code generation, review, and testing. While documentation is often neglected under daily pressure, modern tools make maintenance easier, and enforcement can occur during code review. The primary challenge is keeping documentation concise, relevant, and accessible for new engineers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shared context as code&lt;/strong&gt;: Repository rules files (like CLAUDE.md, Cursor rules, or Copilot workspace configs) outlining design patterns, state management, folder structures, and naming conventions improve AI output quality far more than switching models. Version-control these files alongside your code so they evolve naturally with your project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom agents&lt;/strong&gt;: Build custom agents integrated with issue trackers (like Jira or Linear) to process tickets and generate code that strictly complies with your team&#39;s standards.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is an example of a trimmed CLAUDE.md file that codifies conventions otherwise repeatedly explained during peer reviews:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;# CLAUDE.md

## Project
Content-heavy marketing site. Astro for pages; client-side JS only in islands, and only where interactivity is genuinely required. TypeScript throughout.

## Core principle: Less JS, more platform
Reach for a native HTML element or a CSS feature before a library or a framework component. Justify every new dependency in the PR description, with its bundle-size cost.

## Conventions
- Components: PascalCase, one per file, styles colocated (Card.astro + Card.css).
- Semantic HTML first: button, nav, dialog, details, never a div with an onClick.
- State: prefer the platform (URL params, form state, :has()) over client state; add a store only when state is shared across islands.
- Styling: design tokens from tokens.css. No inline styles, no magic numbers.

## Performance budgets (enforced in CI)
- Field targets (CrUX, not just Lighthouse): LCP &amp;lt; 2.5s, CLS &amp;lt; 0.1, INP &amp;lt; 200ms.
- No render-blocking JS. Images use width/height to reserve space; below-the-fold is lazy-loaded.

## Accessibility (non-negotiable)
- Keyboard-operable and visibly focusable for every interactive element.
- Label every control; don&#39;t add ARIA where native semantics already do the job.
- Modals: native dialog element with showModal().

## Don&#39;t
- Introduce a state-management library for local state.
- Hand-roll what the platform provides (dialogs, disclosure, date inputs).&lt;/code&gt;
&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;#rung-3-guarding&quot; id=&quot;rung-3-guarding&quot;&gt;Rung 3: Guarding&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What it looks like&lt;/strong&gt;: You have established automated guardrails to catch predictable AI errors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The defining failure&lt;/strong&gt;: Guardrails are defensive. They catch bad code but do not actively develop engineers, which brings us to rung 4.&lt;/p&gt;
&lt;p&gt;Code review is frequently an engineering bottleneck, and AI can exacerbate it by generating massive pull requests that overwhelm human reviewers.&lt;/p&gt;
&lt;p&gt;On my previous team, we spent significant effort resolving this bottleneck through two targeted strategies.
First, we introduced automated initial reviews via tools like CodeRabbit, refining configurations based on recurring edge cases. Over time, low-risk pull requests, such as minor refactors and library upgrades, no longer required manual approval. However, this approach relies entirely on a comprehensive, trustworthy automated test suite that catches regressions reliably.&lt;/p&gt;
&lt;p&gt;While mechanical reviews were automated, feature additions still required human oversight. To resolve this, we enforced a strict small-PR policy, breaking feature work into reviewable increments so engineers could thoroughly evaluate diffs rather than rubber-stamping massive pull requests.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How you climb&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Smaller PRs&lt;/strong&gt;: Merge small, incremental pull requests into feature branches to maintain manageable review scopes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testing&lt;/strong&gt;: High testing standards remain essential as delivery speeds accelerate. Avoid reliance on superficial coverage metrics. While tools like Playwright and Keploy aid test generation, AI models default to happy paths. Engineers must explicitly define edge cases and non-standard workflows. Additionally, AI assistance lowers the barrier to adopting Test-Driven Development (TDD).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automated safe approvals&lt;/strong&gt;: Configure workflows to evaluate change impact, automatically approving low-risk pull requests to relieve review bottlenecks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a href=&quot;#automated-guardrails-targeting-common-failure-modes&quot; id=&quot;automated-guardrails-targeting-common-failure-modes&quot;&gt;Automated guardrails targeting common failure modes (failure vs automated check)&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hallucinated dependencies&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;AI models frequently generate non-existent package recommendations. A research study analyzing 576,000 code samples across 16 models found that roughly 20% of suggested packages were fictitious (&lt;a href=&quot;http://arxiv.org/abs/2406.10279&quot; target=&quot;_blank&quot;&gt;&amp;quot;We Have a Package for You!&amp;quot;, USENIX Security 2025&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This predictable behavior heightens susceptibility to slopsquatting attacks. Enforce lockfile and dependency validation in CI.&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Accessibility violations&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;AI assistants often resolve immediate accessibility errors suboptimally, such as cluttering non-semantic markup with excessive ARIA attributes rather than using clean semantic HTML elements. I wrote more about it on &lt;a href=&quot;https://amandavilela.me/blog/using-chrome-devtools-mcp-to-debug-web-accessibility/&quot;&gt;Using Chrome DevTools MCP to debug web accessibility&lt;/a&gt; post.&lt;/p&gt;
&lt;p&gt;Enforce semantics on accessibility code generation and review.&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;&lt;strong&gt;Main-thread performance degradation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As highlighted by &lt;a href=&quot;https://developer.chrome.com/blog/top-10-things-ai-gets-wrong-in-web-dev&quot; target=&quot;_blank&quot;&gt;Chrome&#39;s engineering team&lt;/a&gt;: While models effectively implement basic load-time optimizations (such as offloading heavy computations to Web Workers), they frequently struggle with main-thread responsiveness and Interaction to Next Paint (INP). They routinely miss layout isolation, priority scheduling, and off-thread rendering primitives.&lt;/p&gt;
&lt;p&gt;Mitigate this with lab performance budgets for long tasks and CI checks for main-thread execution time, alongside real-user INP monitoring.&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;&lt;strong&gt;Security vulnerabilities&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Incorporate static application security testing (SAST) and secret scanning into CI pipelines. Research shows that roughly 40% of programs generated by AI assistants across security-sensitive scenarios contained vulnerabilities listed in the CWE Top 25 (&lt;a href=&quot;http://arxiv.org/abs/2108.09293&quot; target=&quot;_blank&quot;&gt;&amp;quot;Asleep at the Keyboard?&amp;quot;, Pearce et al., IEEE S&amp;amp;P 2022&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Treat generated code as untrusted until verified by automated tools and human review.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#rung-4-growing&quot; id=&quot;rung-4-growing&quot;&gt;Rung 4: Growing&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;What it looks like&lt;/strong&gt;: Code review and developer growth are intentional, leveraging AI to empower engineers who thoroughly understand the systems they deploy.
&lt;strong&gt;The defining failure&lt;/strong&gt;: It represents the only sustainable level. Refined technical judgment improves AI usage, which in turn further sharpens developer skills.&lt;/p&gt;
&lt;p&gt;While AI accelerates execution and catches superficial issues, engineers must actively understand root errors, refine prompts, and improve system architecture. Without conscious effort, teams fall into repetitive feedback loops. Engineers must maintain strong ownership of their code. Otherwise, control over the development lifecycle erodes.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#the-invisible-metric-comprehension-debt&quot; id=&quot;the-invisible-metric-comprehension-debt&quot;&gt;The invisible metric: Comprehension debt&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://addyosmani.com/blog/comprehension-debt/&quot; target=&quot;_blank&quot;&gt;Addy Osmani defines comprehension debt&lt;/a&gt; as the gradual loss of human understanding and memory caused by over-reliance on AI automation. In agentic workflows, this debt accumulates quietly through hundreds of casual code reviews where tests passed, and changes looked plausible. Unlike technical debt, comprehension debt often goes unnoticed until critical systems break. Mitigating it requires deliberate cultural changes.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#fostering-a-culture-that-prevents-comprehension-debt&quot; id=&quot;fostering-a-culture-that-prevents-comprehension-debt&quot;&gt;Fostering a culture that prevents comprehension debt&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Comprehension debt is addressed through team culture, not software tools. Clear, human-centered documentation serves as the primary defense. Beyond maintainable documentation, teams should adopt specific operational practices:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ask &amp;quot;walk me through why this works&amp;quot;&lt;/strong&gt;: Make code walkthroughs standard during peer reviews of AI-assisted PRs; if the author cannot explain the implementation, it is not ready to merge.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Host AI-free coding sessions&lt;/strong&gt;: Conduct regular coding dojos or katas without AI assistants to keep core engineering skills sharp, preserving the critical judgment needed to evaluate generated code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pair-program on new features&lt;/strong&gt;: Pair engineers even when using AI tools; two developers with shared understanding provide far better oversight than a single developer trusting model output.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Deep technical comprehension has to stay non-negotiable, for companies and for engineers thinking about the long-term career they want to build.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#knowing-where-you-stand&quot; id=&quot;knowing-where-you-stand&quot;&gt;Knowing where you stand&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A maturity model requires objective metrics to track progress and identify regression.&lt;/p&gt;
&lt;p&gt;Metrics provide visibility into team adoption, delivery speed, and code quality. Standard DORA metrics can be augmented to track code churn, review bottlenecks, testing delays, and return on tooling investments.&lt;/p&gt;
&lt;p&gt;Distinguish between vanity metrics (such as acceptance rate or generated lines of code) and actionable indicators: increased rework rates, defect escape rates, and extended review times signal that code generation is outpacing human review capacity. Always evaluate tool subscription costs against measurable efficiency gains.&lt;/p&gt;
&lt;p&gt;Regularly audit custom prompts and AI agent configurations to remove outdated conventions and prevent models from generating deprecated code.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reaching-the-top-is-a-new-beginning&quot; id=&quot;reaching-the-top-is-a-new-beginning&quot;&gt;Reaching the top is a new beginning&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Climbing the rungs of AI maturity takes continuous effort. Organizational pressures — onboarding, tight deadlines, reviewer fatigue — can pull teams back to earlier rungs if guardrails and review standards slip.&lt;/p&gt;
&lt;p&gt;Your tool ecosystem should work cohesively while engineers keep deep familiarity with the codebase. Automated review tools should reference your documentation standards, generation tools should enforce project conventions, and team culture must prioritize comprehension. Disconnected tools plus disengaged engineers produce isolated productivity spikes rather than lasting progress.&lt;/p&gt;
&lt;p&gt;An AI engineering ecosystem is never 100% done. Even after reaching the Growing rung, you can drop back into experimenting with new techniques and new processes; that&#39;s healthy. As models and capabilities evolve, teams have to keep adapting their workflows. Successful engineering organizations focus not on adopting every emerging tool, but on maintaining a structured process for evaluating tools against their technical stack, security requirements, and team culture.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://addyosmani.com/blog/comprehension-debt/&quot; target=&quot;_blank&quot;&gt;Comprehension Debt - the hidden cost of AI generated code - addyosmani.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/blog/top-10-things-ai-gets-wrong-in-web-dev&quot; target=&quot;_blank&quot;&gt;Top 10 things AI gets wrong in web development - developer.chrome.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/html/2406.10279v3&quot; target=&quot;_blank&quot;&gt;We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs - USENIX Security 2025&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/html/2108.09293v3&quot; target=&quot;_blank&quot;&gt;Asleep at the Keyboard? Assessing the Security of GitHub Copilot&#39;s Code Contributions - Pearce et al., IEEE S&amp;amp;P 2022&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://getdx.com/blog/dora-metrics/&quot; target=&quot;_blank&quot;&gt;DORA metrics: the complete guide to measuring DevOps performance in the AI era - getdx.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>Less JS, more platform: A hands-on test of Declarative Partial Updates</title>
        <link href="https://amandavilela.me/blog/declarative-partial-updates-hands-on-test/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/declarative-partial-updates-hands-on-test/</id>
        <published>2026-08-20T00:00:00.000Z</published>
        <updated>2026-08-20T00:00:00.000Z</updated>
        <summary>A hands-on test of Chrome&#39;s Declarative Partial Updates: out-of-order HTML streaming, setHTML/streamHTML, and where it breaks.</summary>
        <category term="frontend" />
        <content type="html" xml:base="https://amandavilela.me/blog/declarative-partial-updates-hands-on-test/">&lt;p&gt;I&#39;ve always been an advocate for the web platform and its capabilities. In 2017, with the rise of JS frameworks, I gave a talk named &amp;quot;Maybe you don&#39;t need a JS framework&amp;quot;, in which I presented and explained a set of JS features (modules, template strings, promises, fetch API) that could help people build a robust, lightweight page with dynamic content and templates.&lt;/p&gt;
&lt;p&gt;In May this year, the Chrome team released a preview of Declarative Partial Updates, where you can stream content into any part of a page as it becomes ready. It made me really curious because, with vanilla JS, we&#39;ve traditionally had to rely on quite a few tricks to achieve the same result.&lt;/p&gt;
&lt;p&gt;In this article, I&#39;ll explain the Declarative Partial Updates capabilities with a test case and analyze its pros and cons.&lt;/p&gt;
&lt;nav aria-labelledby=&quot;toc-title&quot; class=&quot;table-of-contents&quot;&gt;
    &lt;h2 id=&quot;toc-title&quot;&gt;Table of Contents&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;a href=&quot;#what-are-declarative-partial-updates&quot;&gt;What are Declarative Partial Updates?&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#out-of-order-streaming&quot;&gt;Out-of-order streaming&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#html-insertion-and-streaming-methods&quot;&gt;HTML insertion and streaming methods&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#frameworks-vs-platform&quot;&gt;Frameworks vs. Platform&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#a-test-case&quot;&gt;A test case&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#what-worked-well&quot;&gt;What worked well&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#friction-points&quot;&gt;Friction points&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#browser-support-gaps&quot;&gt;Browser support gaps&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
&lt;h2&gt;&lt;a href=&quot;#what-are-declarative-partial-updates&quot; id=&quot;what-are-declarative-partial-updates&quot;&gt;What are Declarative Partial Updates?&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Declarative Partial Updates is a set of proposed Web Platform APIs that enable out-of-order HTML streaming directly in the browser and provide new JavaScript methods for dynamically updating parts of an existing document.&lt;/p&gt;
&lt;p&gt;These APIsare ready for developer testing from Chrome 148 using the &lt;code&gt;chrome://flags/#enable-experimental-web-platform-features&lt;/code&gt; flag.&lt;/p&gt;
&lt;p&gt;Currently, we have two ways of rendering HTML on the page:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;render the whole page server-side;&lt;/li&gt;
&lt;li&gt;rely on JS frameworks or play with limited JS features to deliver components asynchronously.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Declarative Partial Updates can help us handle HTML content insertion and deliver out-of-order HTML natively, instead of relying on JS. Let&#39;s look at how they work.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#out-of-order-streaming&quot; id=&quot;out-of-order-streaming&quot;&gt;Out-of-order streaming&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The new out-of-order streaming APIs use processing instruction placeholders to mark insertion points in the DOM, allowing late-arriving HTML inside &lt;code&gt;&amp;lt;template for=&amp;quot;...&amp;quot;&amp;gt;&lt;/code&gt; elements to automatically target and fill those spots as it streams in.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;section&amp;gt;
&amp;lt;?marker name=&amp;quot;template-name&amp;quot;&amp;gt;&amp;lt;/section&amp;gt;

&amp;lt;template for=&amp;quot;template-name&amp;quot;&amp;gt;
This is my HTML template :)
&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the browser encounters the &lt;code&gt;&amp;lt;?marker name=&amp;quot;template-name&amp;quot;&amp;gt;&lt;/code&gt; processing instruction, holds that spot in the DOM. Once a matching &lt;code&gt;&amp;lt;template for=&amp;quot;template-name&amp;quot;&amp;gt;&lt;/code&gt; arrives, the browser replaces the marker with the template’s contents, resulting in the following DOM structure:&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;section&amp;gt;
This is my HTML template :)
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;A note on syntax:&lt;/strong&gt; you&#39;ll also see &lt;code&gt;&amp;lt;?start name=&amp;quot;...&amp;quot;&amp;gt;...fallback content...&amp;lt;?end&amp;gt;&lt;/code&gt; used in the wild (and in my test case below) instead of a bare &lt;code&gt;&amp;lt;?marker&amp;gt;&lt;/code&gt;. They&#39;re doing the same reconciliation job, a &lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt; will patch either, but &lt;code&gt;&amp;lt;?start&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;?end&amp;gt;&lt;/code&gt; wraps a &lt;em&gt;range&lt;/em&gt; of fallback content that gets replaced, rather than marking a single insertion point. In practice this matters for skeleton/loading states:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;?marker&amp;gt;&lt;/code&gt; is for a spot with genuinely nothing to show yet.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;?start&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;?end&amp;gt;&lt;/code&gt; is for a spot where you want a skeleton, spinner, or &amp;quot;Loading...&amp;quot; text visible right away, which then gets swapped out entirely when the template patches in.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;a href=&quot;#html-insertion-and-streaming-methods&quot; id=&quot;html-insertion-and-streaming-methods&quot;&gt;HTML insertion and streaming methods&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;These new methods provide a way to deliver that HTML incrementally. While JavaScript already offers ways to inject HTML such as &lt;code&gt;setHTML&lt;/code&gt;, &lt;code&gt;setHTMLUnsafe&lt;/code&gt;, &lt;code&gt;innerHTML&lt;/code&gt;, &lt;code&gt;outerHTML&lt;/code&gt;, &lt;code&gt;createContextualFragment&lt;/code&gt;, and &lt;code&gt;insertAdjacentHTML&lt;/code&gt;, they allrequire a lot of effort to implement a good experience that sanitizes HTML, overrides/appends content, etc.&lt;/p&gt;
&lt;p&gt;To address these inconsistencies, Chrome has proposed expanding the setHTML and setHTMLUnsafe family with a full suite of insertion and streaming APIs:&lt;/p&gt;
&lt;div class=&quot;table-scroll&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Static&lt;/th&gt;
&lt;th&gt;Streaming&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Set the HTML contents of the element&lt;/td&gt;
&lt;td&gt;&lt;code&gt;setHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replace the entire element with this HTML&lt;/td&gt;
&lt;td&gt;&lt;code&gt;replaceWithHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamReplaceWithHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the HTML before the element&lt;/td&gt;
&lt;td&gt;&lt;code&gt;beforeHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamBeforeHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the HTML as the first child of the element&lt;/td&gt;
&lt;td&gt;&lt;code&gt;prependHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamPrependHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the HTML as the last child of the element&lt;/td&gt;
&lt;td&gt;&lt;code&gt;appendHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamAppendHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the HTML after the element&lt;/td&gt;
&lt;td&gt;&lt;code&gt;afterHTML(html, options);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;streamAfterHTML(options);&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;p&gt;There are also &amp;quot;unsafe&amp;quot; versions of each of the APIs, but prefer the standard methods (e.g., &lt;code&gt;setHTML()&lt;/code&gt;) with a &lt;code&gt;Sanitizer&lt;/code&gt; instance over the &lt;code&gt;...Unsafe&lt;/code&gt; variants. The &lt;code&gt;...Unsafe&lt;/code&gt; methods bypass browser sanitization, potentially exposing your application to XSS attacks. Only use &lt;code&gt;Unsafe&lt;/code&gt; methods when you are certain the source HTML is trustworthy or has been sanitized independently.&lt;/p&gt;
&lt;p&gt;When you insert &lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt; using a non-streaming method like &lt;code&gt;setHTML()&lt;/code&gt; or &lt;code&gt;innerHTML&lt;/code&gt;, the browser parses that HTML into an intermediate document fragment first, and reconciliation only happens inside that fragment, it can&#39;t reach out and patch a marker that&#39;s already live in the DOM. Only the streaming path (&lt;code&gt;streamHTML()&lt;/code&gt;, &lt;code&gt;streamHTMLUnsafe()&lt;/code&gt;) skips the intermediate fragment and lets a late-arriving &lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt; patch a marker that&#39;s already rendered on the page. This is exactly why my test case opens a writer via &lt;code&gt;streamHTML()&lt;/code&gt; instead of calling &lt;code&gt;setHTML()&lt;/code&gt; in a loop: with &lt;code&gt;setHTML()&lt;/code&gt;, the shuffled, out-of-order arrival of each match&#39;s data simply wouldn&#39;t reach the markers already sitting in the DOM.&lt;/p&gt;
&lt;section class=&quot;info-box note&quot;&gt;
&lt;strong&gt;The rule of thumb:&lt;/strong&gt; if you&#39;re inserting a marker and its matching template in the same call, either method works, you&#39;re building both in the same parse. But if the marker is already on the page and you&#39;re filling it in later, separately (which is the whole point of out-of-order streaming, markers render first, real content trickles in after), you need &lt;code&gt;streamHTML()&lt;/code&gt;. The non-streaming methods simply can&#39;t reach a marker that already exists outside the fragment they just parsed.
&lt;/section&gt;
&lt;h2&gt;&lt;a href=&quot;#frameworks-vs-platform&quot; id=&quot;frameworks-vs-platform&quot;&gt;Frameworks vs. Platform&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;React&#39;s streaming SSR and other libraries have long relied on userland techniques for out-of-order delivery, using JavaScript to manipulate the DOM as content arrives. Declarative Partial Updates embraces a pattern the ecosystem has independently reinvented for over a decade, shifting that responsibility away from JavaScript and into the HTML parser itself.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#a-test-case&quot; id=&quot;a-test-case&quot;&gt;A test case&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I created this small project to exercise Chrome&#39;s proposed DPU APIs. It fetches data from the Football API and renders the next 5 matches of Campeonato Brasileiro 2026, using the new methods (&lt;code&gt;setHTML&lt;/code&gt;/&lt;code&gt;streamHTML&lt;/code&gt;/etc.) plus a declarative out-of-order patching mechanism using &lt;code&gt;&amp;lt;?start&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;?end&amp;gt;&lt;/code&gt; markers and &lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is the GitHub repository: &lt;a href=&quot;https://github.com/amandavilela/test-dpu&quot; target=&quot;_blank&quot;&gt;https://github.com/amandavilela/test-dpu&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Core functionality&lt;/h3&gt;
&lt;p&gt;Two pieces work together:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A marker pair sits wherever content will eventually land:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;div&amp;gt;&amp;lt;?start name=&amp;quot;match-3&amp;quot;&amp;gt;...fallback content...&amp;lt;?end&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;A &lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt; element, which can arrive anywhere else, at any time, targets that marker by name:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;template for=&amp;quot;match-3&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ticket&amp;quot;&amp;gt;...&amp;lt;/div&amp;gt;&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The browser&#39;s parser reconciles them regardless of arrival order, that&#39;s the &amp;quot;out-of-order&amp;quot; part.&lt;/p&gt;
&lt;p&gt;This is the primary advantage of the renewed HTML insertion and streaming methods (&lt;code&gt;streamHTML()&lt;/code&gt;, etc.): they pipe text through the actual HTML parser (not a plain fragment parse like &lt;code&gt;innerHTML&lt;/code&gt;), so this marker/template reconciliation kicks in even for a targeted DOM update, not just a full-page navigation.&lt;/p&gt;
&lt;h3&gt;Feature detection&lt;/h3&gt;
&lt;p&gt;Before using these experimental APIs, verify support:&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-js&quot;&gt;if (&amp;quot;setHTML&amp;quot; in Element.prototype) {
  // Safe to use native API
} else {
  // Fallback to existing methods or load polyfill
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note this only detects the static insertion methods. If your implementation depends on the streaming/out-of-order patching behavior specifically (as mine does), you&#39;ll also want to check for &lt;code&gt;streamHTML&lt;/code&gt; separately, since a browser could ship one without the other during the rollout.&lt;/p&gt;
&lt;h3&gt;Initial shell render&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;shellMarkup(5)&lt;/code&gt; builds 5 &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; skeletons, each with a marker pair wrapping fallback content (&lt;code&gt;&amp;quot;00/XXX/00:00&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;Fixture loading...&amp;quot;&lt;/code&gt;), rendered immediately on page load and again on every button click.&lt;/p&gt;
&lt;h3&gt;Simulating out-of-order arrival&lt;/h3&gt;
&lt;p&gt;It shuffles the match indices (&lt;code&gt;shuffle(...)&lt;/code&gt;) so fixtures resolve in a genuinely different order each run, opens a writer via &lt;code&gt;ticketsEl.streamHTML({ sanitizer: cardSanitizer }).getWriter()&lt;/code&gt;, writes the shell first, then writes each &lt;code&gt;&amp;lt;template for=&amp;quot;match-N&amp;quot;&amp;gt;&lt;/code&gt; chunk with a randomized delay between writes.&lt;/p&gt;
&lt;p&gt;From there, the browser itself is entirely responsible for finding each marker and splicing the template content in — this code never touches the DOM to insert fixture data.&lt;/p&gt;
&lt;figure&gt;
    &lt;video width=&quot;720&quot; height=&quot;362&quot; controls loading=&quot;lazy&quot;&gt;
        &lt;source src=&quot;declarative_partial_updates_test.mp4&quot; type=&quot;video/mp4&quot;&gt;
        &lt;source src=&quot;declarative_partial_updates_test.webm&quot; type=&quot;video/webm&quot;&gt;
        Your browser does not support the video tag.
    &lt;/video&gt;
    &lt;figcaption&gt;Test execution from skeleton loading to content hydration&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2&gt;&lt;a href=&quot;#what-worked-well&quot; id=&quot;what-worked-well&quot;&gt;What worked well&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reduced JavaScript payload:&lt;/strong&gt; No framework runtime is required to reconcile out-of-order content, the parser does it natively.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Streaming-friendly, works with server-rendered content:&lt;/strong&gt; No client-side hydration step, the DOM you get is the DOM you wanted, with no diffing pass.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Native XSS sanitization:&lt;/strong&gt; The safe method variants sanitize by default, which removes a class of manual work (DOMPurify-style sanitization) that a hand-rolled streaming solution would otherwise need to own.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;a href=&quot;#friction-points&quot; id=&quot;friction-points&quot;&gt;Friction points&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;Content-only replacement&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;template for&amp;gt;&lt;/code&gt; swaps what&#39;s between the markers, never attributes on the wrapping element. So a loading-state attribute like &lt;code&gt;aria-busy&lt;/code&gt; on the &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; can&#39;t be cleared by the patch itself, that requires an external bridge (a &lt;code&gt;MutationObserver&lt;/code&gt;, the same trick we already use for &lt;code&gt;.skeleton&lt;/code&gt;).&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;function watchNativeResolution(container, total) {
    let resolvedCount = 0;
    const observer = new MutationObserver(() =&amp;gt; {
      container.querySelectorAll(&#39;li.ticket.skeleton&#39;).forEach((li) =&amp;gt; {
        if (li.querySelector(&#39;.pending&#39;)) return;

        markResolved(li);
        resolvedCount += 1;
        const index = li.id.split(&#39;-&#39;)[1];
        log(`match-${index} resolved → native declarative patch (out of order)`);
        if (resolvedCount === total) {
          log(&#39;stream complete — all fixtures resolved out of order&#39;);
        }
      });
    });
    observer.observe(container, { childList: true, subtree: true });
    return observer;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Focus loss on replacement&lt;/h3&gt;
&lt;p&gt;Despite the name, &amp;quot;partial update&amp;quot; doesn&#39;t mean DOM diffing. The old subtree is destroyed and a new one inserted, so a focused element inside the swapped region loses focus, and there&#39;s no hook to restore it on the native path.&lt;/p&gt;
&lt;figure&gt;
    &lt;video width=&quot;720&quot; height=&quot;362&quot; controls loading=&quot;lazy&quot;&gt;
        &lt;source src=&quot;focus_loss_declarative_partial_updates.mp4&quot; type=&quot;video/mp4&quot;&gt;
        &lt;source src=&quot;focus_loss_declarative_partial_updates.webm&quot; type=&quot;video/webm&quot;&gt;
        Your browser does not support the video tag.
    &lt;/video&gt;
    &lt;figcaption&gt;Focus loss after content replacement&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h3&gt;No defined announcement semantics&lt;/h3&gt;
&lt;p&gt;If the newly inserted content represents an important user-facing update that should be announced, developers might need to supply an &lt;code&gt;aria-live&lt;/code&gt; region proactively, same as for any other dynamic content.&lt;/p&gt;
&lt;h3&gt;No JS hook at the moment of native resolution&lt;/h3&gt;
&lt;p&gt;The browser patches markers mid-parse with no callback, so there&#39;s no way to wrap that specific swap in a View Transition, or to programmatically compensate scroll/layout at that instant.&lt;/p&gt;
&lt;p&gt;These insertion and accessibility issues can be handled with a &lt;code&gt;MutationObserver&lt;/code&gt;, but depending on how complex the UI is, accessibility can be seriously hurt or become very hard to manage manually.&lt;/p&gt;
&lt;h3&gt;Sanitizer API support gap&lt;/h3&gt;
&lt;p&gt;The safe &lt;code&gt;setHTML&lt;/code&gt;/&lt;code&gt;streamHTML&lt;/code&gt; path depends on the Sanitizer API, which isn&#39;t supported in Safari today. If you need the safe variants cross-browser, you&#39;re currently blocked outside Chromium, which is important to consider before using this for anything shipping soon.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#browser-support-gaps&quot; id=&quot;browser-support-gaps&quot;&gt;Browser support gaps&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Currently, these features are experimental. Developers should feature-detect these APIs, and the Chrome team has released an &lt;a href=&quot;https://github.com/GoogleChromeLabs/html-setters-polyfill&quot; target=&quot;_blank&quot;&gt;html-setters-polyfill&lt;/a&gt; for broader compatibility until support is finalized, however, Sanitizer API is a gap for this functionality as it does not work in Safari.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#final-thoughts&quot; id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Today, streaming server-rendered applications typically rely on JavaScript to find placeholders, reconcile incoming HTML, and move it into the correct position.&lt;/p&gt;
&lt;p&gt;Declarative Partial Updates move that responsibility to the browser, but that doesn&#39;t automatically translate into better performance. Rendering performance still depends on the amount of DOM work being performed, layout costs, CSS, and the rest of the page, however, it does remove a layer of application code that previously existed only to glue streamed content together.&lt;/p&gt;
&lt;p&gt;As these APIs mature, I see them fitting naturally into an &amp;quot;islands architecture,&amp;quot; particularly for applications where most of the page remains server-rendered.&lt;/p&gt;
&lt;p&gt;What initially caught my attention was how much JavaScript could be deleted by offloading this work to browser primitives. Ultimately, though, I view Declarative Partial Updates as a structural architectural improvement with potential performance benefits, rather than a guaranteed performance optimization.&lt;/p&gt;
&lt;p&gt;Back in 2017, I argued that we might not need heavy JS frameworks to build robust web applications, I still believe that, the web has evolved a lot, and many complex behaviors can now be handled natively. Even so, Declarative Partial Updates won&#39;t be a replacement for frameworks, instead, it will potentially influence how frameworks manage partial content updates.&lt;/p&gt;
&lt;p&gt;Special thanks to &lt;a href=&quot;https://www.linkedin.com/in/taraojo/&quot; target=&quot;_blank&quot;&gt;Tara Ojo Agyemang&lt;/a&gt; for her clarification and contributions to the demo project in this post.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.chrome.com/blog/declarative-partial-updates&quot; target=&quot;_blank&quot;&gt; Declarative partial updates - developer.chrome.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>Chrome DevTools MCP: debugging Core Web Vitals and performance</title>
        <link href="https://amandavilela.me/blog/chrome-devtools-mcp-core-web-vitals/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/chrome-devtools-mcp-core-web-vitals/</id>
        <published>2026-07-09T00:00:00.000Z</published>
        <updated>2026-07-09T00:00:00.000Z</updated>
        <summary>A walkthrough of using Chrome DevTools MCP and Modern Web Guidance with Claude to audit and fix Core Web Vitals and performance issues.</summary>
        <category term="core web vitals" />
        <content type="html" xml:base="https://amandavilela.me/blog/chrome-devtools-mcp-core-web-vitals/">&lt;p&gt;Chrome DevTools MCP Server enables a direct connection between your browser and AI coding assistants, providing real-time context of the active session and making debugging and fixes more accurate.&lt;/p&gt;
&lt;p&gt;In this post, I’ll walk through how to set up the Chrome DevTools MCP Server with the Claude Code + Modern Web Guidance, and share my experience using the tool to debug the performance of a real-world site.&lt;/p&gt;
&lt;nav aria-labelledby=&quot;toc-title&quot; class=&quot;table-of-contents&quot;&gt;
    &lt;h2 id=&quot;toc-title&quot;&gt;Table of Contents&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;a href=&quot;#install-chrome-devtools-mcp&quot;&gt;Installing Chrome DevTools MCP&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#installing-modern-web-guidance&quot;&gt;Installing Modern Web Guidance&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#debugging-performance&quot;&gt;Debugging performance&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;
                    &lt;a href=&quot;#the-report&quot;&gt;The audit report and suggested fixes&lt;/a&gt;
                    &lt;ul&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#lab-vs-field&quot;&gt;Lab data vs. field data&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#overview&quot;&gt;Overview&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#third-party-scripts&quot;&gt;Third-party scripts and main thread blocking&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#network-dependency-tree&quot;&gt;Network dependency tree and preconnects&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#forced-reflow&quot;&gt;Forced reflow and layout thrashing&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#dom-size&quot;&gt;DOM size&lt;/a&gt;
                        &lt;/li&gt;
                        &lt;li&gt;
                            &lt;a href=&quot;#lighthouse-scores&quot;&gt;Image delivery and caching &amp;amp; Lighthouse scores&lt;/a&gt;
                        &lt;/li&gt;
                    &lt;/ul&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
&lt;p&gt;Chrome DevTools MCP is an open-source bridge that lets AI coding assistants &amp;quot;see&amp;quot; and interact with a live Chrome browser.&lt;/p&gt;
&lt;p&gt;In my previous post, &lt;a href=&quot;/blog/using-chrome-devtools-mcp-to-debug-web-accessibility&quot; target=&quot;_blank&quot;&gt;Debugging Page Accessibility Issues with Chrome DevTools MCP Server&lt;/a&gt;, you can find more details about what MCP (Model Context Protocol) is and how it works.&lt;/p&gt;
&lt;section class=&quot;info-box disclaimer&quot;&gt;
    &lt;p&gt;This audit uses &lt;a href=&quot;https://www.forbes.com&quot; target=&quot;_blank&quot;&gt;www.forbes.com&lt;/a&gt; as a case study to explore the capabilities of the Chrome DevTools MCP Server for performance debugging. I picked this site just to provide an example of a complex, real-world UI.&lt;/p&gt;
    &lt;p&gt;The intention is not to evaluate the company or its teams, but to understand how the tool performs in practice.&lt;/p&gt;
&lt;/section&gt;
&lt;p&gt;With that context in place, let&#39;s start testing the Chrome DevTools MCP Server&#39;s performance debugging capabilities.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#install-chrome-devtools-mcp&quot; id=&quot;install-chrome-devtools-mcp&quot;&gt;Installing Chrome DevTools MCP&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To get started, you&#39;ll need an &lt;strong&gt;AI tool&lt;/strong&gt; on your terminal. Chrome DevTools MCP works with a &lt;a href=&quot;https://github.com/ChromeDevTools/chrome-devtools-mcp?tab=readme-ov-file#mcp-client-configuration&quot; target=&quot;_blank&quot;&gt;large range of clients&lt;/a&gt;; in this tutorial, I&#39;m using &lt;a href=&quot;https://claude.com/&quot; target=&quot;_blank&quot;&gt;Claude&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is the command to install Chrome DevTools MCP server and add it to Claude&#39;s list of MCP servers:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;claude mcp add chrome-devtools --scope user npx chrome-devtools-mcp@latest&lt;/code&gt;
&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;#installing-modern-web-guidance&quot; id=&quot;installing-modern-web-guidance&quot;&gt;Installing Modern Web Guidance&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Skills are packages containing instructions and optional scripts that extend AI agent capabilities with specialized knowledge and workflows. In the accessibility post I mentioned at the beginning of this article, I used &lt;a href=&quot;https://github.com/addyosmani/agent-skills&quot; target=&quot;_blank&quot;&gt;Addy Osmani Agent Skills&lt;/a&gt;. This time, just to experiment with something different, I&#39;m using &lt;a href=&quot;https://developer.chrome.com/docs/modern-web-guidance&quot; target=&quot;_blank&quot;&gt;Modern Web Guidance&lt;/a&gt;, an open-source project by the Google Chrome team and the Microsoft Edge team, in collaboration with the wider web development community, launched in May 2026.&lt;/p&gt;
&lt;p&gt;Modern Web Guidance is a set of skills that embed web platform expertise, best practices, and browser compatibility data directly into your coding agents.&lt;/p&gt;
&lt;p&gt;To install Modern Web Guidance, you can simply run on your terminal:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;# 1. Add the marketplace:
/plugin marketplace add GoogleChrome/modern-web-guidance
# 2. Install the plugin
/plugin install modern-web-guidance@googlechrome
# 3. Reload plugins
/reload-plugins&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;To check modern-web-guidance is properly installed, open Claude and run:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/modern-web-guidance&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;It should return:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;This skill helps me look up modern web development best practices before implementing a feature. I don&#39;t see a specific implementation task in your message yet — what are you looking to build or check guidance for?&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;#debugging-performance&quot; id=&quot;debugging-performance&quot;&gt;Debugging performance&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that everything is set up, let&#39;s start the &lt;strong&gt;performance debugging&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This was my prompt in order to get the performance audit:&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;Audit the performance and Core Web Vitals forbes.com on mobile slow 4g on incognito window
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You do not need to use explicit slash commands to activate Modern Web Guidance. Claude Code skills utilize semantic matching, and the tool automatically triggers whenever you ask Claude to write frontend code or audit web-related features.&lt;/p&gt;
&lt;p&gt;Chrome DevTools MCP doesn&#39;t have a literal &amp;quot;incognito&amp;quot; toggle, but Claude achieved the same isolation by opening the page in a fresh, isolated browser context (no shared cookies or cached state from prior sessions), then emulating a mobile viewport (412×915, 2.625 DPR), Slow 4G network throttling, and a 4× CPU slowdown before recording the trace.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;performance-audit-chrome-dev-tools-mcp-modern-guidance-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;329&quot;&gt;
    &lt;source srcset=&quot;performance-audit-chrome-dev-tools-mcp-modern-guidance-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;144&quot;&gt;
    &lt;img src=&quot;performance-audit-chrome-dev-tools-mcp-modern-guidance-320w.webp&quot; width=&quot;300&quot; height=&quot;144&quot; loading=&quot;lazy&quot; alt=&quot;Claude Code terminal output showing the agent running the Chrome DevTools MCP performance audit on forbes.com, including progress updates and the resulting Core Web Vitals table comparing lab and field LCP, CLS, and INP results.&quot;&gt;
    &lt;figcaption&gt;Claude starting the performance audit on forbes.com&lt;/figcaption&gt;
&lt;/picture&gt;
&lt;h3&gt;&lt;a href=&quot;#the-report&quot; id=&quot;the-report&quot;&gt;The audit report and suggested fixes&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Claude generated an audit report with key performance issues found on forbes.com:&lt;/p&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the full audit&lt;/summary&gt;
    &lt;pre&gt;
&lt;code&gt;Forbes.com — Mobile / Slow 4G / Incognito Performance Audit
&lt;p&gt;Test conditions: Pixel-class viewport (412x915, mobile+touch), Slow 4G network
throttling, 4x CPU throttling, isolated (incognito-like) browser context.&lt;/p&gt;
&lt;p&gt;Core Web Vitals
Metric | Lab (this run)  | Field (CrUX, real users, p75)  | Field verdict
LCP    | 554 ms          | 2,212 ms                       | Good (&amp;lt;=2.5s)
CLS    | 0.00            | 0.00                           | Good
INP    | n/a             | 220 ms                         | Needs Improvement (threshold 200ms)&lt;/p&gt;
&lt;p&gt;Notable discrepancy: lab LCP (554ms) is far faster than what real users see
(2,212ms) — real-world TTFB is 1,126ms vs. 12ms in this run, meaning the CDN
edge/cache state in this session wasn&#39;t representative of a typical real
user&#39;s server latency.&lt;/p&gt;
&lt;p&gt;Key findings&lt;br&gt;
1 - Third-party weight is heavy, ad-tech dominates main-thread cost
Largest transfer: Integral Ad Science (211 kB), Media.net (38 kB), BlueConic (29 kB), Google/DoubleClick Ads (21 kB)
Largest main-thread time: Google CDN (1,358 ms), forbesimg.com (1,352 ms), DoubleClick Ads (838 ms), GTM (827 ms), ketchjs.com/consent management (692 ms), DoubleVerify (638 ms), ISAS (632 ms), BlueConic (618 ms)
Combined, ad/consent/measurement scripts account for several seconds of main-thread work under 4x CPU throttling.&lt;/p&gt;
&lt;p&gt;2 - Network dependency chain is deep — 1,986ms critical path
Longest chain: forbes.com → VWO (A/B testing) loader → VWO CDN scripts → nested VWO scripts (1.86–1.99s deep). Font files (Graphik, Schnyder, Highlander — 4 separate woff2 files) also load late in the chain (up to 1.5s).
Preconnect issue: 5+ preconnect hints declared (over Chrome&#39;s recommended max of 4), and several are unused/empty-origin — wasted connection setup.&lt;/p&gt;
&lt;p&gt;3 - Forced reflow — 885ms total, dominated by an updateSize function in framework-*.js (745ms) and unattributed layout work (231ms), interleaved with ad-related scripts (DoubleVerify, AdSafeProtected, GPT) querying layout properties.&lt;/p&gt;
&lt;p&gt;4 - DOM size: 5,804 elements, depth 25 — not extreme, but style recalculations spike as high as 491ms affecting 856 elements at once, likely triggered by late-arriving ad/consent content.&lt;/p&gt;
&lt;p&gt;5 - Image delivery: ~20 kB of wasted bytes; LCP image itself (an imageio.forbes.com JPEG served as WebP) loaded fast (85μs download) and isn&#39;t the bottleneck — the issue is that 86.9% of LCP time lab-side is render delay, not resource loading, consistent with heavy main-thread contention from third parties blocking paint.&lt;/p&gt;
&lt;p&gt;Lighthouse (non-performance categories, mobile)
Accessibility: 80
Best Practices: 54 ⚠️ (low — usually driven by third-party issues: console errors, deprecated APIs, insecure requests from ad partners)
SEO: 85
Agentic Browsing: 50&lt;/p&gt;
&lt;p&gt;Bottom line
Forbes&#39;s Core Web Vitals pass in aggregate (LCP/CLS good, INP borderline per CrUX), but the site carries a heavy, ad-tech-driven third-party burden that&#39;s the real risk factor: the deep critical-path chain (VWO test loader), the forced-reflow time, and the depressed Best Practices score. On genuinely slow connections/devices (closer to what this throttled run simulates), real users are more exposed to these ad-script costs than the p75 field aggregate suggests.&lt;/p&gt;
&lt;p&gt;Screenshot of the loaded homepage is attached above. Raw trace saved to forbes_mobile_slow4g_incognito_trace.json in the repo root.&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;After getting the audit, I asked for fixes for the issues found. Here&#39;s the full list:&lt;/p&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the full list of fixes&lt;/summary&gt;
    &lt;pre&gt;
&lt;code&gt;Here are concrete fixes mapped to each issue found, based on Chrome&#39;s current performance best practices:
    1. Third-party weight dominating main thread (ISAS, DoubleClick, GTM, ketchjs, BlueConic, DoubleVerify — several seconds combined)
    This is also the real reason LCP&#39;s render-delay phase ate 86.9% of the budget even though the image itself loaded in 85μs — the main thread was busy running ad/consent/measurement JS.
    - Defer/async everything non-essential, load it after first paint rather than blocking it.
    - Deprioritize with fetchpriority=&amp;quot;low&amp;quot; on scripts like analytics/verification tags that don&#39;t need to compete with content for bandwidth.
    - Consider a facade pattern for below-the-fold ad units — don&#39;t initialize the full ad-tech stack (IAS, DoubleVerify, etc.) until those slots approach the viewport.
    &amp;lt;script src=&amp;quot;/js/verification-tag.js&amp;quot; async fetchpriority=&amp;quot;low&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
    2. Critical path depth (1,986ms) — VWO A/B testing loader chain
    forbes.com → VWO loader → 2 nested VWO scripts is the longest chain in the trace, and it&#39;s not rendering-critical.
    - Move the VWO snippet to load async, not synchronously in &amp;lt;head&amp;gt; — A/B test frameworks blocking the critical path for 2 seconds on Slow 4G is a significant, avoidable cost.
    - Trim the preconnect list. You have 5+ preconnects (max recommended is 4) and several point to empty/unused origins — each one costs a real DNS+TLS handshake on a slow connection for no benefit. Keep only i.forbesimg.com (fonts/images) and cdn.ketchjs.com (consent, needed early) as preconnects; downgrade the rest to dns-prefetch or drop them.
    3. Forced reflow (885ms total, updateSize in framework-*.js = 745ms)
    Layout-property reads (getBoundingClientRect, offsetWidth) are interleaved with DOM writes across ad-related code (DoubleVerify, AdSafeProtected, GPT).
    - Batch reads before writes — never alternate element.offsetHeight (read) with element.style.height = ... (write) in a loop.
    - Where the app is sizing containers dynamically, prefer ResizeObserver over synchronous geometry polling — it reports size changes without forcing a layout.
    4. Font loading chain (4 separate woff2 files, up to 1.5s deep in the chain)
    - Preload only the 1-2 fonts used above the fold with fetchpriority and crossorigin; the other weights can load later.
    &amp;lt;link rel=&amp;quot;preload&amp;quot; href=&amp;quot;/assets/fonts/Graphik/Graphik-Regular-Web.woff2&amp;quot; as=&amp;quot;font&amp;quot; type=&amp;quot;font/woff2&amp;quot; crossorigin&amp;gt;
    - Given 4 custom families are in play, add font-size-adjust: from-font on body text containers so the fallback-to-webfont swap doesn&#39;t itself cause a layout shift while these load.
&lt;p&gt;Net effect
Most of these findings trace back to one root cause: ad-tech and experimentation scripts are on the critical rendering path instead of being deferred/isolated. Fixing the preconnect list, deferring the VWO loader, and containing ad-slot layout would likely resolve the CLS spike, shrink the 1.9s critical chain, and free up the main thread that&#39;s currently delaying LCP&#39;s render phase — without touching content code at all.
Since this is an audit of a third-party site (not your own codebase), these are recommendations for Forbes&#39;s engineering team rather than changes I can apply directly — useful as the &amp;quot;how to fix it&amp;quot; section of your blog post alongside the trace data.&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;Let&#39;s go through each finding below and see whether the suggested fix actually holds up.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#lab-vs-field&quot; id=&quot;lab-vs-field&quot;&gt;Lab data vs. field data&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Before looking at any single metric, I want to clarify the two kinds of data mixed into this report, since they measure different things and can genuinely disagree.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lab data&lt;/strong&gt; is what Chrome DevTools MCP recorded directly: one page load, on one emulated device, under one set of throttling conditions. It&#39;s fully reproducible and lets you attribute a slow metric to a specific script or resource, but it&#39;s still just a sample of one.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Field data&lt;/strong&gt; comes from &lt;a href=&quot;https://developer.chrome.com/docs/crux&quot; target=&quot;_blank&quot;&gt;CrUX (the Chrome User Experience Report)&lt;/a&gt;: measurements from real Chrome users who actually visited a website, aggregated over a rolling 28-day window and reported at the 75th percentile (p75, meaning 75% of real visits were at least this good). It reflects the full spread of devices, networks, geographies, and cache states Forbes&#39;s actual audience experiences, but it can&#39;t tell you &lt;em&gt;why&lt;/em&gt; a metric is slow, only &lt;em&gt;that&lt;/em&gt; it is.&lt;/p&gt;
&lt;p&gt;Neither is &amp;quot;more correct&amp;quot;; they&#39;re answering different questions. Lab data helps you debug a specific, reproducible issue, while field data tells you whether that issue actually matters to real users and whether your lab result generalizes at all. This audit&#39;s own numbers make a good case for using both.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#overview&quot; id=&quot;overview&quot;&gt;Overview&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The report opens by comparing this run&#39;s lab metrics against field data, and right away something stands out: the two disagree, in opposite directions.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Metric | Lab (this run) | Field (CrUX, real users, p75) | Field verdict
LCP    | 554 ms          | 2,212 ms                       | Good
CLS    | 0.00            | 0.00                           | Good
INP    | n/a             | 220 ms                         | Needs Improvement

Notable discrepancy: lab LCP (554ms) is far faster than what real users see
(2,212ms) — real-world TTFB is 1,126ms vs. 12ms in this run.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Lab LCP looked great here mostly because this session&#39;s CDN edge happened to be warm, so the 12ms TTFB isn&#39;t what most real visitors get. Field TTFB (1,126ms) is nearly 100× higher, and it&#39;s the real bottleneck for most users, something this single lab run never surfaced. Read side by side, it&#39;s a live example of why a single lab trace should never be trusted on its own; field data is what actually tells you whether a result is representative or a fluke.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#third-party-scripts&quot; id=&quot;third-party-scripts&quot;&gt;Third-party scripts and main thread blocking&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;
&lt;code&gt;1 - Third-party weight is heavy, ad-tech dominates main-thread cost
  - Largest transfer: Integral Ad Science (211 kB), Media.net (38 kB), BlueConic (29 kB), Google/DoubleClick Ads (21 kB)
  - Largest main-thread time: Google CDN (1,358 ms), forbesimg.com (1,352 ms), DoubleClick Ads (838 ms), GTM (827 ms), ketchjs.com/consent management (692 ms), DoubleVerify (638 ms), ISAS (632 ms), BlueConic (618 ms)
  - Combined, ad/consent/measurement scripts account for several seconds of main-thread work under 4x CPU throttling.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Over 30 distinct third-party origins show up in the trace, and the transfer-size ranking and the main-thread-time ranking don&#39;t line up: Integral Ad Science is the single largest payload (211 kB), but Google CDN, which barely registers on the transfer list, costs more CPU time (1,358ms) than any single third party&#39;s download. Bytes-over-the-wire and CPU cost are two separate budgets, and 4× CPU throttling makes the CPU one much more visible. That CPU budget is what&#39;s blocking the LCP paint, and it&#39;s hurting INP too.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#lcp-render-delay&quot; id=&quot;lcp-render-delay&quot;&gt;LCP&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;LCP breaks down into four phases: &lt;strong&gt;TTFB&lt;/strong&gt; (server responds), &lt;strong&gt;load delay&lt;/strong&gt; (browser discovers the resource needs fetching), &lt;strong&gt;load duration&lt;/strong&gt; (the download itself), and &lt;strong&gt;render delay&lt;/strong&gt; (time from &amp;quot;resource is ready&amp;quot; to &amp;quot;pixels are actually painted&amp;quot;). Here, the first three phases are essentially free. The featured article image already follows best practice (&lt;code&gt;fetchpriority=&amp;quot;high&amp;quot;&lt;/code&gt;, high network priority) and finishes downloading in 85 &lt;em&gt;microseconds&lt;/em&gt;. By 79ms into the page load, the browser has the fully decoded image sitting in memory, ready to paint.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;forbes-lcp-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;forbes-lcp-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;forbes-lcp-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&quot;Chrome DevTools Elements panel highlighting the forbes.com LCP hero image element, showing its fetchpriority=&amp;quot;high&amp;quot; attribute already applied.&quot;&gt;
&lt;/picture&gt;
&lt;p&gt;The browser is single-threaded for this kind of work: painting, JavaScript execution, style recalculation, and layout all compete for the same main thread. An image can&#39;t be painted while that thread is busy running something else. In this trace, that &amp;quot;something else&amp;quot; shows up clearly in the other findings below: up to 632ms of Integral Ad Science execution, 618ms of BlueConic, 745ms inside Forbes&#39;s own &lt;code&gt;updateSize&lt;/code&gt; reflow loop, and a single 491ms style recalculation touching 856 elements, &lt;strong&gt;all fighting over the same thread&lt;/strong&gt; the browser needs to flip from &amp;quot;image decoded&amp;quot; to &amp;quot;image painted.&amp;quot; The resource pipeline did its job perfectly, but the rendering pipeline was simply too busy to use the result 😔&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;lcp-waterfall-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;lcp-waterfall-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;lcp-waterfall-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&quot;Chrome DevTools Performance panel showing the LCP breakdown insight for forbes.com&quot;&gt;
    &lt;figcaption&gt;481ms LCP render delay while the main thread runs script evaluation and style recalculation&lt;/figcaption&gt;
&lt;/picture&gt;
&lt;p&gt;This is also why the field render delay (610ms) and lab render delay (481ms) are much closer to each other than TTFB is: main-thread contention from third-party scripts is a fairly consistent tax regardless of network conditions, whereas TTFB is almost entirely a function of server/CDN distance, which is exactly where lab and field diverged most in the overview section.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#fix-third-party-scripts&quot; id=&quot;fix-third-party-scripts&quot;&gt;Fix from Modern Web Guidance&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Here&#39;s what Modern Web Guidance recommends for third-party management:&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;!-- Defer non-essential tags, don&#39;t let them compete with content --&amp;gt;
&amp;lt;script src=&amp;quot;/js/verification-tag.js&amp;quot; async fetchpriority=&amp;quot;low&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the ad verification/viewability scripts specifically (IAS, DoubleVerify), a facade pattern that only initializes them once their ad unit nears the viewport via &lt;code&gt;IntersectionObserver&lt;/code&gt; would avoid paying their main-thread cost during initial load at all.&lt;/p&gt;
&lt;p&gt;Example code:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;&amp;lt;div class=&amp;quot;ad-slot&amp;quot; data-ad-unit=&amp;quot;leaderboard-1&amp;quot;&amp;gt;
    &amp;lt;!-- ad renders here once loaded --&amp;gt;
&amp;lt;/div&amp;gt;

const adObserver = new IntersectionObserver((entries, observer) =&gt; {
    entries.forEach((entry) =&gt; {
        if (!entry.isIntersecting) return;
    
        const slot = entry.target;
        loadAdScript(slot.dataset.adUnit);
    
        // Only need to trigger once per slot
        observer.unobserve(slot);
    });
    }, {
    // Start loading before the slot is actually on screen,
    // so the ad is ready by the time the user scrolls to it
    rootMargin: &#39;200px&#39;,
});

document.querySelectorAll(&#39;.ad-slot&#39;).forEach((slot) =&gt; {
    adObserver.observe(slot);
});

function loadAdScript(adUnit) {
    const script = document.createElement(&#39;script&#39;);
    script.src = `https://ads.example.com/tag.js?unit=${encodeURIComponent(adUnit)}`;
    script.async = true;
    document.body.appendChild(script);
}&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#network-dependency-tree&quot; id=&quot;network-dependency-tree&quot;&gt;Network dependency tree and preconnects&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The single longest dependency chain on the page isn&#39;t an ad. It&#39;s Forbes&#39;s own A/B testing tool. VWO&#39;s chain is 4 levels deep, and each level has to wait for the previous one&#39;s response before the browser even knows what to fetch next.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;2 - Network dependency chain is deep — 1,986ms critical path
Longest chain: forbes.com → VWO (A/B testing) loader → VWO CDN scripts → nested VWO scripts (1.86–1.99s deep). Font files (Graphik, Schnyder, Highlander — 4 separate woff2 files) also load late in the chain (up to 1.5s).
Preconnect issue: 5+ preconnect hints declared (over Chrome&#39;s recommended max of 4), and several are unused/empty-origin — wasted connection setup.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The VWO loader kicks off a nested chain of scripts that stacks up to almost 2 seconds before the browser can move on.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;network-dependency-tree-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;network-dependency-tree-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;network-dependency-tree-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&quot;Chrome DevTools Performance panel for forbes.com showing the network dependency tree insight: a chain from the page to VWO&#39;s j.php and nested scripts with a 1.99 s max critical path latency, plus a warning that more than 4 preconnect connections were found.&quot;&gt;
&lt;/picture&gt;
&lt;p&gt;That makes it a different kind of problem than the ad scripts. Transfer size is only 11.1 kB, tiny enough that it&#39;s not a bandwidth issue, and main-thread time is just 4ms, negligible next to Google CDN&#39;s 1,358ms or IAS&#39;s 632ms. The real cost here is pure network latency.&lt;/p&gt;
&lt;p&gt;So why build it this way? This nested-loader pattern is the classic signature of client-side A/B testing anti-flicker behavior. Tools like VWO traditionally have to load a loader script, fetch which experiment variant the visitor is in, fetch the code or CSS for that variant, and apply it, all before the page is allowed to paint. Otherwise the visitor briefly sees the &amp;quot;control&amp;quot; version flash to the &amp;quot;variant&amp;quot; version. Historically, testing platforms solved this with an &lt;code&gt;opacity: 0&lt;/code&gt; trick plus an arbitrary timeout (often 4 seconds) that hides the whole page until the chain resolves, which is exactly why this script ends up front-loaded and chained instead of deferred.&lt;/p&gt;
&lt;p&gt;There was no &lt;strong&gt;INP&lt;/strong&gt; record on lab metrics, but the field data shows 220ms, meaning the main-thread contention from third-party scripts and the A/B testing chain was keeping real users from interacting with the page right away.&lt;/p&gt;
&lt;p&gt;Layered on top of that, the page declares more &lt;code&gt;preconnect&lt;/code&gt; hints than Chrome recommends, and a few of them point at origins that are never actually requested, wasting early-connection budget for nothing.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#fix-network-dependency-tree&quot; id=&quot;fix-network-dependency-tree&quot;&gt;Fix from Modern Web Guidance&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;There&#39;s now a purpose-built browser primitive for exactly this: &lt;code&gt;blocking=&amp;quot;render&amp;quot;&lt;/code&gt; on a &lt;code&gt;&amp;lt;script&amp;gt;/&amp;lt;link&amp;gt;&lt;/code&gt; in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, combined with async, which blocks paint, not HTML parsing, until the script runs, replacing the old opacity-hack-and-4-second-timeout approach entirely:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;script src=&amp;quot;https://cdn.example.com/experiment-sdk.js&amp;quot; async blocking=&amp;quot;render&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The key architectural change Modern Web Guidance recommends: &lt;strong&gt;split the tiny &amp;quot;avoid flicker&amp;quot; logic&lt;/strong&gt; from the heavy SDK. A small render-blocking stub applies just a data-variant attribute on &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; (keeping a strict performance budget, ~100ms), while the rest of VWO&#39;s tracking/logic loads separately with plain async, no blocking. That removes the deep sequential chain because the only thing gating paint becomes small and fast, not the 4-level nested loader currently in place.&lt;/p&gt;
&lt;p&gt;One caveat: &lt;a href=&quot;https://caniuse.com/wf-blocking-render&quot; target=&quot;_blank&quot;&gt;blocking=&amp;quot;render&amp;quot;&lt;/a&gt; isn&#39;t supported in Firefox, so a lightweight fallback (feature-detected, opacity + timeout) is still needed there, but even that fallback is a big improvement over the current ~2-second chain, since it&#39;s a single toggle rather than four sequential round trips.&lt;/p&gt;
&lt;p&gt;Modern Web Guidance also recommends preloading only the 1-2 fonts used above the fold with fetchpriority and crossorigin. Since 4 custom families are in play, add &lt;code&gt;font-size-adjust: from-font&lt;/code&gt; on body text containers so the fallback-to-webfont swap doesn&#39;t itself cause a layout shift while these load.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#forced-reflow&quot; id=&quot;forced-reflow&quot;&gt;Forced reflow and layout thrashing&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;
&lt;code&gt;3 - Forced reflow — 885ms total, dominated by an updateSize function in framework-*.js (745ms) and unattributed layout work (231ms), interleaved with ad-related scripts (DoubleVerify, AdSafeProtected, GPT) querying layout properties.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;updateSize&lt;/code&gt;, in Forbes&#39;s own &lt;code&gt;175-*.js&lt;/code&gt; bundle, is by far the largest single contributor, accounting for 745ms of the 885ms total. The name and the pattern (a JS function reading layout geometry after DOM writes) point to a resize or measurement loop mixing reads and writes in the same tick: classic layout thrashing, and part of the same main-thread contention described in the LCP section above. It&#39;s also the most actionable finding in this report, since it&#39;s first-party code, not a vendor script Forbes doesn&#39;t control.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#fix-forced-reflow&quot; id=&quot;fix-forced-reflow&quot;&gt;Fix from Modern Web Guidance&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Batch reads before writes, and swap &lt;code&gt;offsetWidth&lt;/code&gt;/&lt;code&gt;getBoundingClientRect&lt;/code&gt; polling for &lt;code&gt;ResizeObserver&lt;/code&gt;.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-js&quot;&gt;async function updateSize(elements) {
  for (const el of elements) {
    const width = el.offsetWidth;      // read
    await scheduler.yield();           // yield between read and write
    el.style.setProperty(&#39;--w&#39;, width + &#39;px&#39;); // write
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#dom-size&quot; id=&quot;dom-size&quot;&gt;DOM size&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;
&lt;code&gt;4 - DOM size: 5,804 elements, depth 25 — not extreme, but style recalculations spike as high as 491ms affecting 856 elements at once, likely triggered by late-arriving ad/consent content.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;This is a classic issue on content portals: with close to 6,000 elements on the page, a single style recalculation touches as many as 856 of them at once (491ms). That&#39;s the other half of the main-thread story from the LCP section: a large chunk of the DOM has to be re-evaluated any time something invalidates styles high enough up the tree, and each of these recalculations is more main-thread time the browser can&#39;t spend painting.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#fix-dom-size&quot; id=&quot;fix-dom-size&quot;&gt;Fix from Modern Web Guidance&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Applying &lt;code&gt;content-visibility: auto&lt;/code&gt; on below-the-fold article cards shrinks the scope of these recalculations without touching the component tree.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code class=&quot;language-css&quot;&gt;.article-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#lighthouse-scores&quot; id=&quot;lighthouse-scores&quot;&gt;Image delivery and caching &amp;amp; Lighthouse scores&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The report even included information about image delivery and Lighthouse scores.&lt;/p&gt;
&lt;p&gt;It shows that image delivery and caching aren&#39;t the bottleneck here (the images arrive quickly and are cached effectively), but the render delay is what&#39;s blocking paint.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Image delivery: ~20 kB of wasted bytes; LCP image itself (an imageio.forbes.com JPEG served as WebP) loaded fast (85μs download) and isn&#39;t the bottleneck — the issue is that 86.9% of LCP time lab-side is render delay, not resource loading, consistent with heavy main-thread contention from third parties blocking paint.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;There&#39;s also evidence the site has room to improve beyond performance:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Accessibility: 80
Best Practices: 54
SEO: 85
Agentic Browsing: 50
Passed: 46, Failed: 13&lt;/code&gt;
&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;#final-thoughts&quot; id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chrome DevTools MCP Server, Claude, and Modern Web Guidance were useful for spotting real, specific performance issues on the page, and the fixes it pulled were consistent and easy to act on, down to exact file names and line numbers for Forbes&#39;s own code, not just vendor scripts.&lt;/p&gt;
&lt;p&gt;One thing that stood out to me was how much overloading the main thread can affect performance even if you apply best practices to other parts of the page. An image can follow every LCP best practice, including high fetch priority, fast download, no lazy-loading, and still render half a second late, because painting has to wait in line behind whatever else is occupying the main thread. Nearly every other finding in this report (ad-tech scripts, the VWO loader chain, forced reflow, style recalculation) is really the same root cause showing up in different insights: too much competing for one thread.&lt;/p&gt;
&lt;p&gt;Another important reminder is that lab and field data tell two different stories, which is only obvious if you deliberately compare the two rather than trusting either in isolation.&lt;/p&gt;
&lt;p&gt;It&#39;s a solid tool for auditing and debugging, and a reliable source of actionable suggestions. It can guide your attention, but it still requires a critical eye to interpret and validate its recommendations, especially where the trace itself admits it &amp;quot;couldn&#39;t identify a root cause.&amp;quot; Even so, I see a lot of potential and I really liked the idea of having a community set of guidelines and best practices layered on top of the MCP&#39;s output.&lt;/p&gt;
&lt;p&gt;I intend to adopt these tools in my workflow, and I recommend you do the same, as the Chrome DevTools MCP receives frequent updates and AI agents continue to advance.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/docs/modern-web-guidance/disciplines&quot; target=&quot;_blank&quot;&gt;Explore Modern Web Guidance disciplines - developer.chrome.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/articles/preconnect-and-dns-prefetch&quot; target=&quot;_blank&quot;&gt;Establish network connections early to improve perceived page speed - web.dev&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/performance/third-party-facades&quot; target=&quot;_blank&quot;&gt;Lazy load third-party resources with facades - developer.chrome.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.debugbear.com/blog/forced-reflows&quot; target=&quot;_blank&quot;&gt;How To Fix Forced Reflows And Layout Thrashing - debugbear.com&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>How Core Web Vitals can impact your business revenue</title>
        <link href="https://amandavilela.me/blog/how-core-web-vitals-can-impact-business-revenue/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/how-core-web-vitals-can-impact-business-revenue/</id>
        <published>2026-06-23T00:00:00.000Z</published>
        <updated>2026-06-23T00:00:00.000Z</updated>
        <summary>Discover how optimizing Core Web Vitals can boost your conversions. Learn why milliseconds mean millions and how to claim your lost revenue today.</summary>
        <category term="core web vitals" />
        <content type="html" xml:base="https://amandavilela.me/blog/how-core-web-vitals-can-impact-business-revenue/">&lt;p&gt;In the digital economy, user attention is the most valuable currency. You can spend thousands of dollars on flawless copywriting, pixel-perfect design, and aggressive SEO campaigns, but if your website feels slow, your hard-earned traffic will vanish before it even loads.&lt;/p&gt;
&lt;p&gt;Google’s introduction of Core Web Vitals (CWV) helped quantify what many businesses were already experiencing: slow websites just frustrate users and can directly impact revenue.&lt;/p&gt;
&lt;p&gt;Check the Core Web Vitals section on &lt;a href=&quot;https://search.google.com/search-console/core-web-vitals&quot; target=&quot;_blank&quot;&gt;Google Search Console&lt;/a&gt;. If your metrics are in the &amp;quot;needs improvement&amp;quot; or &amp;quot;poor&amp;quot; zone, there&#39;s a good chance you&#39;re paying for traffic that isn&#39;t converting as effectively as it could.&lt;/p&gt;
&lt;p&gt;In the next sections, I&#39;ll explain why optimizing Core Web Vitals can be one of the highest-ROI investments a business can make.&lt;/p&gt;
&lt;h2 id=&quot;every-0-1-seconds-of-slow-loading-time-costs&quot;&gt;&lt;a href=&quot;#every-0-1-seconds-of-slow-loading-time-costs&quot;&gt;Every 0.1 seconds of slow loading time costs&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Many businesses assume their site is &amp;quot;fast enough&amp;quot;, but a study by Deloitte and Google, Milliseconds Make Millions, analyzed over 30 million user sessions across major brands and found that even a 0.1-second improvement in mobile site speed can trigger a measurable jump in consumer spending:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Retail/E-commerce&lt;/strong&gt;: A 0.1-second boost resulted in an 8.4% increase in conversion rates and a 9.2% increase in average order value. Consumers simply spend more when the friction is gone.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Luxury Brands&lt;/strong&gt;: Progression from the product detail page to the &amp;quot;Add to Basket&amp;quot; step jumped by 40.1%.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lead Generation&lt;/strong&gt;: Websites capturing leads saw a 21.6% improvement in users successfully reaching and completing the final form submission page.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you think your brand is too big or established to be impacted by minor performance issues, look at Vodafone.&lt;/p&gt;
&lt;p&gt;Vodafone ran an A/B test specifically targeting Core Web Vitals optimizations. They built an optimized version of their landing page that improved Largest Contentful Paint (LCP), the metric for how fast the main content loads, by 31%.&lt;/p&gt;
&lt;p&gt;The results were clear: &lt;strong&gt;a 8% increase in total sales/conversions, a 15% improvement in their lead-to-visit ratio, and an 11% increase in cart visits&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;triple-win-seo-ads-and-bounce-rates&quot;&gt;&lt;a href=&quot;#triple-win-seo-ads-and-bounce-rates&quot;&gt;Triple win: SEO, ads, and bounce rates&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Optimizing your Core Web Vitals can tackle 3 critical business issues simultaneously:&lt;/p&gt;
&lt;h3 id=&quot;lower-search-rankings-seo&quot;&gt;&lt;a href=&quot;#lower-search-rankings-seo&quot;&gt;Lower search rankings (SEO)&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Google explicitly uses Core Web Vitals as a ranking factor. If your competitor&#39;s site provides a faster, more visually stable experience, Google will reward them with higher organic positioning.&lt;/p&gt;
&lt;h3 id=&quot;wasted-ad-spend&quot;&gt;&lt;a href=&quot;#wasted-ad-spend&quot;&gt;Wasted ad spend&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you pay for ads you pay for the click. If a user clicks your ad but the page takes 4 seconds to become interactive, they will bounce. You are effectively paying tech giants to frustrate your potential clients. Faster sites yield lower bounce rates and a higher Return on Ad Spend (ROAS).&lt;/p&gt;
&lt;h3 id=&quot;cart-abandonment&quot;&gt;&lt;a href=&quot;#cart-abandonment&quot;&gt;Cart abandonment&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A separate study on the business impact of Web Vitals (check the reading recommendations section) found that when the agricultural marketplace Agrofy improved their LCP by 70%, they saw a 76% reduction in cart abandonment.&lt;/p&gt;
&lt;h2 id=&quot;the-3-metrics-you-need-to-know&quot;&gt;&lt;a href=&quot;#the-3-metrics-you-need-to-know&quot;&gt;The 3 metrics you need to know&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To fix your site, you must know what Google is grading you on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Largest Contentful Paint (LCP)&lt;/strong&gt;: Measures loading speed. The main content of your page should load within 2.5 seconds of the page starting to load.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interaction to Next Paint (INP)&lt;/strong&gt;: Measures responsiveness. This tracks how fast your site reacts when a user clicks a button, opens a menu, or types into a form. It should be under 200 milliseconds.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cumulative Layout Shift (CLS)&lt;/strong&gt;: Measures visual stability. Have you ever tried to click a link and the page suddenly shifted down because an ad or image loaded late, causing you to click the wrong thing? That is bad CLS. Your score should be under 0.1.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;is-your-website-costing-you-customers&quot;&gt;&lt;a href=&quot;#is-your-website-costing-you-customers&quot;&gt;Is your website costing you customers?&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Many businesses don&#39;t realize they have a Core Web Vitals problem until they notice declining conversion rates, reduced engagement, or lost revenue opportunities.&lt;/p&gt;
&lt;p&gt;When you optimize your Core Web Vitals, you aren&#39;t just pleasing Google&#39;s algorithm, you&#39;re removing friction for your customers, maximizing the return on your marketing spend, and making sure your digital storefront operates at its highest possible capacity. In a marketplace where competitors are only a click away, speed isn&#39;t just an advantage, it&#39;s survival.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/case-studies/milliseconds-make-millions&quot; target=&quot;_blank&quot;&gt;Milliseconds make millions - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/case-studies/vitals-business-impact&quot; target=&quot;_blank&quot;&gt;The business impact of Core Web Vitals - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/case-studies/vodafone&quot; target=&quot;_blank&quot;&gt;Vodafone: A 31% improvement in LCP increased sales by 8% - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>From Sass and BEM to modern CSS: A migration journey in 4 acts</title>
        <link href="https://amandavilela.me/blog/sass-bem-to-modern-css-migration/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/sass-bem-to-modern-css-migration/</id>
        <published>2026-05-12T00:00:00.000Z</published>
        <updated>2026-05-12T00:00:00.000Z</updated>
        <summary>A deep dive into refactoring this blog. Learn how native CSS features can replace legacy pre-processors and naming conventions to create a faster, leaner codebase.</summary>
        <category term="web performance" />
        <content type="html" xml:base="https://amandavilela.me/blog/sass-bem-to-modern-css-migration/">&lt;p&gt;In March of this year, I started redesigning my website and building this blog.
Between choosing design patterns and static-site tools, I took one thing for granted: my styling workflow. I just stuck with the ecosystem I knew best: &lt;strong&gt;Sass, BEM, and standard CSS&lt;/strong&gt;, without giving it a second thought.&lt;/p&gt;
&lt;p&gt;With the recent &lt;a href=&quot;https://web.dev/baseline&quot; target=&quot;_blank&quot;&gt;Baseline releases&lt;/a&gt;, I decided to take a look at the CSS of my site and begin this modernization journey, which I will split into 4 acts 🤠&lt;/p&gt;
&lt;nav aria-labelledby=&quot;toc-title&quot; class=&quot;table-of-contents&quot;&gt;
    &lt;h2 id=&quot;toc-title&quot;&gt;Table of Contents&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;a href=&quot;#act-1-modern-css-properties&quot;&gt;Act 1 - Modernizing CSS: Meet new properties&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#css-variables&quot;&gt;CSS variables&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#logical-properties&quot;&gt;Logical properties&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#css-nesting&quot;&gt;CSS nesting&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#modern-selectors&quot;&gt;Modern selectors&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#modern-media-query-syntax&quot;&gt;Modern media query syntax&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#native-color-handling&quot;&gt;Native color handling&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#clamp-fluid-typography&quot;&gt;Clamp, fluid typography without media queries&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#act-2-scope-rule&quot;&gt;Act 2 - @scope: The rule that changed everything&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#scope-over-nesting&quot;&gt;What&#39;s the real gain over regular nesting?&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#scope-proximity&quot;&gt;Solving specificity with scope proximity&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#act-3-abandoning-bem&quot;&gt;Act 3 - The controversial decision: Abandoning BEM&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#replace-bem-for-scope&quot;&gt;Should everybody replace BEM for @scope?&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#use-scope-correctly&quot;&gt;How to use @scope correctly?&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#act-4-need-sass&quot;&gt;Act 4 - Do I really need Sass after all?&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#was-it-worth-it&quot;&gt;Was it all worth it?&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
&lt;h2&gt;&lt;a href=&quot;#act-1-modern-css-properties&quot; id=&quot;act-1-modern-css-properties&quot;&gt;Act 1: Modern CSS Properties&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As we know, CSS has evolved rapidly over the last couple of years. Here are the specific properties I decided to implement to modernize this site’s styles (shout-out to &lt;a href=&quot;https://moderncss.dev/&quot; target=&quot;_blank&quot;&gt;ModernCSS.dev&lt;/a&gt; for the inspiration).&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#css-variables&quot; id=&quot;css-variables&quot;&gt;CSS variables&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;CSS variables have been around since 2017, I had previously relied on Sass variables. Switching to native CSS variables was my first step. The primary advantage is that they are handled at runtime by the browser, unlike Sass variables, I can manipulate them directly in the DevTools to test changes instantly.&lt;/p&gt;
&lt;p&gt;CSS variables are defined via the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/--*&quot; target=&quot;_blank&quot;&gt;custom property syntax&lt;/a&gt; (often within the :root selector) and accessed using the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/var&quot; target=&quot;_blank&quot;&gt;var() function&lt;/a&gt;. For even more control, like defining types or default values, you can also use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@property&quot; target=&quot;_blank&quot;&gt;@property at-rule&lt;/a&gt;.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;:root {
    --color-bg: #FAFAFA;
    --color-text: #5f5f5f;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since April 2017, &lt;a href=&quot;https://caniuse.com/css-variables&quot; target=&quot;_blank&quot;&gt;check css variables support&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#logical-properties&quot; id=&quot;logical-properties&quot;&gt;Logical properties&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;According to MDN, logical properties map layout to the flow of content (start/end) rather than physical directions (top/bottom/left/right). This makes your styles more resilient to different writing modes.&lt;/p&gt;
&lt;p&gt;Beyond future-proofing for internationalization, what I liked the most is how the code gets less verbose. Instead of explicitly defining four separate margins or paddings to target specific axes, we can use concise block and inline values:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Instead of this: */
margin-top: 20px;
margin-bottom: 15px;
padding-left: 30px;
padding-right: 40px;

/* We can simply use: */
margin-block: 20px 15px;
padding-inline: 30px 40px;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It’s important to note that the property values can change depending on the values defined for writing-mode, direction, and text-orientation. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Logical_properties_and_values&quot; target=&quot;_blank&quot;&gt;Check docs of logical properties for more details&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since September 2021, &lt;a href=&quot;https://caniuse.com/css-logical-props&quot; target=&quot;_blank&quot;&gt;check logical properties support&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#css-nesting&quot; id=&quot;css-nesting&quot;&gt;CSS nesting&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Native nesting allows you to nest child rules inside parent rules, making the relationship explicit and your code more organized.&lt;/p&gt;
&lt;p&gt;In practice, it works very similarly to the Sass nesting, but is parsed by the browser rather than being pre-compiled.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Old CSS: */
.link {
    color: var(--color-green);
}
.link:hover {
    color: var(--color-green-dark);
}

/* Modern CSS: */
.link {
    color: var(--color-green);

    &amp;:hover {
        color: var(--color-green-dark);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that &lt;strong&gt;it does not support class name interpolation on the nest as Sass does&lt;/strong&gt;, which might be inconvenient, specially if you are using BEM, which we’ll dive into later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sass:&lt;/strong&gt;&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.hero {
    padding-block: 5rem 1rem;

    &amp;__inner {
        display: flex;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.hero {
    padding-block: 5rem 1rem;

    .hero__inner {
        display: flex;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pseudo-Elements&lt;/strong&gt;: You cannot nest a pseudo-element inside another (e.g., &lt;code&gt;::after { ::before { ... } }&lt;/code&gt; is invalid). The only exceptions are specialized cases like &lt;code&gt;::before::marker&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Order Matters&lt;/strong&gt;: Pseudo-elements must always be at the end of a selector. You can nest a pseudo-element inside a pseudo-class (like &lt;code&gt;:hover::before&lt;/code&gt;), but you cannot put a pseudo-class after a pseudo-element.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since December 2023, &lt;a href=&quot;https://caniuse.com/css-nesting&quot; target=&quot;_blank&quot;&gt;check logical properties support&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#modern-selectors&quot; id=&quot;modern-selectors&quot;&gt;Modern selectors&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;#is&quot; id=&quot;is&quot;&gt;is()&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes&quot; target=&quot;_blank&quot;&gt;:is() pseudo-class&lt;/a&gt; takes a selector list and matches any element in that list. It’s great for reducing code bloat and making styles easier to read.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Instead of repeating selectors: */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-green);
}

/* Use :is() for a cleaner approach: */
:is(h1, h2, h3, h4, h5, h6) {
    color: var(--color-green);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#has&quot; id=&quot;has&quot;&gt;has()&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;:has()&lt;/code&gt; allows you to style an element based on its children or preceding siblings.&lt;/p&gt;
&lt;p&gt;I used this for the hover effect in the header (dimming other links), which was previously only possible with JavaScript or fragile CSS hacks. Now it&#39;s handled natively by the browser&#39;s engine, which is faster and more reliable.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.nav {
    /* Dim other links when one is hovered */
    &amp;:has(.link:hover) .link:not(:hover) {
        opacity: .9;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Performance note&lt;/strong&gt;: Certain uses of &lt;code&gt;:has()&lt;/code&gt; can significantly impact page performance during heavy DOM mutations. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:has#performance_considerations&quot; target=&quot;_blank&quot;&gt;Read has() MDN performance considerations for more detail&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Support:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;is(): Major support since January 2021, &lt;a href=&quot;https://caniuse.com/css-matches-pseudo&quot; target=&quot;_blank&quot;&gt;check is() support&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;has(): Major support since December 2023, &lt;a href=&quot;https://caniuse.com/?search=has%28%29&quot; target=&quot;_blank&quot;&gt;check has() support&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a href=&quot;#modern-media-query-syntax&quot; id=&quot;modern-media-query-syntax&quot;&gt;Modern media query syntax&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This new syntax simplifies the writing and is significantly more intuitive to read than (min-width: 1024px).&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Instead of @media (min-width: 1024px) */
@media (width &gt;= 1024px) {
    align-items: flex-start;
    display: flex;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It also makes &amp;quot;between&amp;quot; queries much cleaner. For example, instead of combining min-width and max-width with an and, you can now write: &lt;code&gt;@media (768px &amp;lt;= width &amp;lt;= 1024px)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since March 2023, &lt;a href=&quot;https://caniuse.com/css-media-range-syntax&quot; target=&quot;_blank&quot;&gt;check modern media query syntax support&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#native-color-handling&quot; id=&quot;native-color-handling&quot;&gt;Native color handling&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/color-mix&quot; target=&quot;_blank&quot;&gt;color-mix()&lt;/a&gt; CSS function allows you to blend two colors in a specified color space directly in your stylesheet.&lt;/p&gt;
&lt;p&gt;I used that to replace Sass functions &lt;code&gt;lighten()&lt;/code&gt; and &lt;code&gt;darken()&lt;/code&gt; to pre-calculate every bubble shade on the 404 page, now the browser can calculate these on the fly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sass&lt;/strong&gt;:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.b6 {
    background: darken($color-salmon, 12%);
}

.b7 {
    background: lighten($color-green, 45%);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;CSS&lt;/strong&gt;:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.b6 {
    background: color-mix(in srgb, var(--color-salmon), black 12%);
}

.b7 {
    background: color-mix(in srgb, var(--color-green), white 45%);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since May 2023, &lt;a href=&quot;https://caniuse.com/wf-color-mix&quot; target=&quot;_blank&quot;&gt;check color-mix() support&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#clamp-fluid-typography&quot; id=&quot;clamp-fluid-typography&quot;&gt;Clamp, fluid typography without media queries&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/clamp&quot; target=&quot;_blank&quot;&gt;clamp() function&lt;/a&gt; defines a value that scales fluidly within a fixed range. It sets a minimum and maximum boundary for a property (like font size or width), with an ideal &amp;quot;preferred&amp;quot; value in between.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Syntax: clamp(min, val, max) */

font-size: clamp(1.85rem, 4vw + 0.75rem, 2.75rem);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;clamp(min, preferred, max)&lt;/code&gt; keeps a value fluid within a fixed range. The browser uses the preferred value (usually dynamic units like vw) as long as it stays between the minimum and maximum bounds.&lt;/p&gt;
&lt;p&gt;Here is the breakdown of what those units do together:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Min&lt;/strong&gt;: 1.85rem ensure the text is never illegible on small screens.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Val&lt;/strong&gt;: By mixing a fixed unit (.75rem) and a fluid unit (4vw), you create a gentle slope. The text still grows, but it grows at a controlled rate.
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;4vw&lt;/strong&gt; means 4% of the current screen width.
This is what makes the text &amp;quot;fluid.&amp;quot; As the browser window gets wider, 4vw gets larger, and the text grows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;.75rem&lt;/strong&gt; (The Static Anchor)&lt;br&gt;By adding .75rem to the calculation, you are giving the font an anchor.
Without this, if the screen was extremely narrow, 4vw could become too small to read or even grow very aggressively on larger monitors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;&lt;strong&gt;Max&lt;/strong&gt;: 2.75rem ensure the text won’t get comically large on ultra-wide monitors.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Concrete Example&lt;/strong&gt;: &lt;code&gt;clamp(1.85rem, 4vw + 0.75rem, 2.75rem)&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;On a small phone (375px width)&lt;/strong&gt;: 4vw (15px) + .75rem (12px) = 27px, since 1.85rem (29.6px) is the minimum, &lt;strong&gt;it stays around 30px&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;On a laptop (1440px width)&lt;/strong&gt;: 4vw (57.6px) + .75rem (12px) = 69.6px, since 2.75rem (44px) is the maximum, the browser &amp;quot;clamps&amp;quot; it and &lt;strong&gt;prvents it from getting bigger than 44px&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The use of clamp() can reduce the amount of CSS/@media queries by allowing elements like typography, padding, or gaps to resize themselves automatically for every single device width.&lt;/p&gt;
&lt;figure&gt;
    &lt;video width=&quot;720&quot; height=&quot;362&quot; controls loading=&quot;lazy&quot;&gt;
        &lt;source src=&quot;media-queries-vs-clamp.mp4&quot; type=&quot;video/mp4&quot;&gt;
        &lt;source src=&quot;media-queries-vs-clamp.webm&quot; type=&quot;video/webm&quot;&gt;
        Your browser does not support the video tag.
    &lt;/video&gt;
    &lt;figcaption&gt;On the left, text sizes jump abruptly at specific breakpoints using CSS Media Queries. On the right, text sizes scale smoothly and continuously using the clamp() function.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Support&lt;/strong&gt;: Major support since July 2020, &lt;a href=&quot;https://caniuse.com/css-math-functions&quot; target=&quot;_blank&quot;&gt;check clamp() support&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#act-2-scope-rule&quot; id=&quot;act-2-scope-rule&quot;&gt;Act 2: @scope — The rule that changed everything&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;One feature that caught my attention was @scope, &lt;a href=&quot;https://caniuse.com/css-cascade-scope&quot; target=&quot;_blank&quot;&gt;available across major browsers since December 2025&lt;/a&gt;, it allows you to limit a selector&#39;s reach to a specific DOM subtree, creating isolated styles.&lt;/p&gt;
&lt;p&gt;I found this especially useful for styling my blog&#39;s body content. Previously, I had to style specific tags under a &lt;code&gt;.post__body&lt;/code&gt; class, which felt awkward as I was following &lt;a href=&quot;https://getbem.com/naming/&quot; target=&quot;_blank&quot;&gt;BEM conventions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before scope:&lt;/strong&gt;&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;.post__body {
    p {
        line-height: 1.7rem;
    }

    p + p {
        margin-top: 1rem;
    }

    h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        margin-top: 2.5rem;
    }

    /*other tags here...*/
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Using scope:&lt;/strong&gt;&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;@scope (.post__body) {
    p {
        line-height: 1.7rem;
    }

    p + p {
        margin-block-start: 1.25rem;
    }

    h2 {
        font-size: 1.5rem;
        margin-block-end: 1rem;
        margin-block-start: 2.5rem;
    }

    /*other tags here...*/
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#scope-over-nesting&quot; id=&quot;scope-over-nesting&quot;&gt;What&#39;s the real gain over regular nesting?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The answer is isolation, with regular nesting, styles &amp;quot;leak&amp;quot; into every descendant. For example, if I embed a newsletter signup component inside a post, the global p styles from &lt;code&gt;.post__body&lt;/code&gt; might accidentally mess up the signup form&#39;s layout.&lt;/p&gt;
&lt;p&gt;To solve this, we can use &lt;strong&gt;Donut Scope&lt;/strong&gt;, a technique that styles a subtree while explicitly excluding nested areas, with this syntax &lt;code&gt;@scope (start) to (end) { ... }&lt;/code&gt;, it’s possible to create a &amp;quot;hole&amp;quot; in the scope where styles don&#39;t apply.&lt;/p&gt;
&lt;p&gt;This is how the donut scope would apply in this case:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/* Style everything inside .post__body EXCEPT what&#39;s inside .newsletter-signup */

@scope (.post__body) to (.newsletter-signup) {
    p {
        line-height: 1.7rem;
    }

    /*other tags here...*/
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#scope-proximity&quot; id=&quot;scope-proximity&quot;&gt;Solving specificity with scope proximity&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another advantage of &lt;code&gt;@scope&lt;/code&gt; is &lt;strong&gt;proximity&lt;/strong&gt;. In traditional CSS, if two selectors have the same specificity, the one defined last in the file wins. &lt;code&gt;@scope&lt;/code&gt; changes the game: the browser applies the style from the &amp;quot;closest&amp;quot; scope root.&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;@scope (.card) {
         p { color: blue; }
   }

   @scope (.section) {
         p { color: red; }
   }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If a &lt;code&gt;.card&lt;/code&gt; is nested inside a &lt;code&gt;.section&lt;/code&gt;, the p will be &lt;strong&gt;blue&lt;/strong&gt; because the &lt;code&gt;.card&lt;/code&gt; root is &amp;quot;closer&amp;quot; to the element than the &lt;code&gt;.section&lt;/code&gt; root, even if the CSS order is different.&lt;/p&gt;
&lt;p&gt;Interesting how it can keep the styles encapsulated and reduce specificity, right?&lt;/p&gt;
&lt;p&gt;There are problems I’m currently solving with BEM naming conventions on this project. It made me wonder... do I actually still need BEM?&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#act-3-abandoning-bem&quot; id=&quot;act-3-abandoning-bem&quot;&gt;Act 3: The controversial decision: Abandoning BEM&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;After experimenting with &lt;code&gt;@scope&lt;/code&gt;, I began to question if BEM (Block, Element, Modifier) still made sense for this project.&lt;/p&gt;
&lt;p&gt;Originally, I adopted BEM for two reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;To scope CSS to specific components.&lt;/li&gt;
&lt;li&gt;To avoid styling conflicts.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Can &lt;code&gt;@scope&lt;/code&gt; achieve this?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;, it allows us to target elements precisely without overly-specific selectors and avoid &amp;quot;style leakage&amp;quot; without increasing specificity. Furthermore, it eliminates the long, repetitive BEM class names that make the maintenance and even refactors difficult.&lt;/p&gt;
&lt;p&gt;So in the case of my project that is a very small project handled by a single developer, it made sense removing BEM and solve the scope and styling conflicts with &lt;code&gt;@scope&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#replace-bem-for-scope&quot; id=&quot;replace-bem-for-scope&quot;&gt;Should everybody replace BEM for @scope?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There are overlaps between &lt;code&gt;@scope&lt;/code&gt; and &lt;code&gt;BEM&lt;/code&gt;, but they don’t need to be replacements.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;@scope handles &lt;strong&gt;proximity-based scoping&lt;/strong&gt;, it limits styles to a DOM subtree.&lt;/li&gt;
&lt;li&gt;BEM handles &lt;strong&gt;naming collisions&lt;/strong&gt; and &lt;strong&gt;visual structure documentation&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is a summary of solutions for both approaches:&lt;/p&gt;
&lt;div class=&quot;table-scroll&quot;&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;BEM&#39;s answer&lt;/th&gt;
&lt;th&gt;@scope&#39;s answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name collision&lt;/td&gt;
&lt;td&gt;Unique verbose names&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Style leaking out&lt;/td&gt;
&lt;td&gt;Naming discipline&lt;/td&gt;
&lt;td&gt;Scope boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nested component bleed&lt;/td&gt;
&lt;td&gt;Elements are never re-used&lt;/td&gt;
&lt;td&gt;to () limit (donut)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Specificity wars&lt;/td&gt;
&lt;td&gt;Always one class&lt;/td&gt;
&lt;td&gt;:scope proximity wins&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;p&gt;It is important to mention that &lt;strong&gt;BEM and @scope can coexist&lt;/strong&gt;. It all depends on the specific problems you are trying to solve. A mixed approach can also be a solution: you can continue using BEM class names for structural clarity while using @scope to encapsulate those styles and manage proximity.&lt;/p&gt;
&lt;p&gt;Before deleting your BEM classes, consider these factors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Support&lt;/strong&gt;: It’s a newer feature and the support is still evolving, so you might need fallbacks depending on your audience and supported browsers;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;: If you have to write &amp;quot;fallback&amp;quot; CSS for older browsers, you might end up with larger bundle sizes. However, for modern browsers, removing long BEM strings actually reduces the HTML/CSS payload.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Team adoption&lt;/strong&gt;: BEM is a global industry standard. Switching to a scoped model requires a shift in how your team thinks about styles.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a href=&quot;#use-scope-correctly&quot; id=&quot;use-scope-correctly&quot;&gt;How to use @scope correctly?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you decided to remove BEM or start using @scope, it is important to establish clear patterns to avoid creating new architectural debt. Since there isn&#39;t an &#39;official&#39; methodology for @scope just yet, here are the rules I’m following to keep my styles organized:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Avoid scoping styles to tags&lt;/strong&gt;: Scoping to a generic tag (like div) is risky. Use a class for your scope root to avoid endup with a lot of style leak to solve.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Naming is still important&lt;/strong&gt;: Use generic class names inside the scope block. This way you can have naming standards on the project, but the CSS remains &amp;quot;locally&amp;quot; valid within its own scope.
&lt;ul&gt;
&lt;li&gt;BEM: .hero__title, .hero__button, .hero__image&lt;/li&gt;
&lt;li&gt;@scope: .title, .button, .image inside @scope (.hero).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don&#39;t rely on @scope to resolve specificity conflicts&lt;/strong&gt;: Don&#39;t use @scope as a crutch to win specificity wars. If you find yourself reaching for !important, your architecture likely needs a rethink. BEM-style &amp;quot;modifiers&amp;quot; (e.g., --large) are still a great way to handle state or variations.&lt;/li&gt;
&lt;/ol&gt;
&lt;section class=&quot;info-box explore&quot;&gt;
    &lt;p&gt;If you liked &lt;code&gt;@scope&lt;/code&gt; for encapsulation, you should look into &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers&quot; target=&quot;_blank&quot;&gt;Cascade Layers&lt;/a&gt;, while &lt;code&gt;@scope&lt;/code&gt; limits where a selector applies, &lt;code&gt;@layer&lt;/code&gt; controls which styles win regardless of specificity.&lt;/a&gt;
&lt;/section&gt;
&lt;h2&gt;&lt;a href=&quot;#act-4-need-sass&quot; id=&quot;act-4-need-sass&quot;&gt;Act 4: Do I really need Sass after all?&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;After modernizing my styles and even removing BEM, I had the ultimate question: &lt;strong&gt;Does Sass still earn its place in my stack?&lt;/strong&gt; I broke it down by the features I use most:&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#sass-variables&quot; id=&quot;sass-variables&quot;&gt;1. Variables&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It makes easier to change theme colors, standarlize spacing etc.&lt;br&gt;
Does native CSS support it? Yes ✅&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#sass-nesting&quot; id=&quot;sass-nesting&quot;&gt;2. Nesting&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Avoids repetitive writing to rules like .btn:hover, .btn:focus&lt;br&gt;
Does native CSS support it? Yes ✅&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#sass-interpolation&quot; id=&quot;sass-interpolation&quot;&gt;3. Interpolation&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Allows you to write style rules inside one another, mirroring your HTML structure. Perfect to avoid writing the long BEM names.&lt;/p&gt;
&lt;p&gt;Does native CSS support it? No ⛔&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You cannot directly append text to a selector using &amp;amp; in native CSS as you can in Sass.&lt;br&gt;&lt;/li&gt;
&lt;li&gt;CSS currently lacks a direct alternative to .#{$variable} interpolation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;How to handle that?&lt;/strong&gt;&lt;br&gt;
No alternative at this moment, so I had to choose repeating class names on the styles, the good thing is that removing BEM, I was able to reduce class names.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#sass-partials-modularity&quot; id=&quot;sass-partials-modularity&quot;&gt;4. Partials &amp;amp; modularity&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Small modules can be shared across the project.&lt;/p&gt;
&lt;p&gt;Is it possible with CSS? Yes, &lt;strong&gt;but with considerations&lt;/strong&gt; ✍️&lt;/p&gt;
&lt;p&gt;CSS has &lt;code&gt;@import&lt;/code&gt; feature available across browsers since July 2015 and it works pretty much like Sass imports do, so on the code writing no problems. I basically renamed all partial &lt;code&gt;.css&lt;/code&gt; and fixed the imports on top of the files.&lt;/p&gt;
&lt;p&gt;However, Sass imports allow multiple imports to be separated by commas rather than requiring each one to have its own &lt;code&gt;@import&lt;/code&gt; and are &lt;strong&gt;handled entirely during compilation&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;CSS &lt;code&gt;@import&lt;/code&gt; equire the browser to &lt;strong&gt;make multiple HTTP requests&lt;/strong&gt; as it renders your page and it can significantly &lt;strong&gt;negative impact&lt;/strong&gt; web performance because it forces the browser to load the stylesheets sequentially rather than in parallel.&lt;/p&gt;
&lt;p&gt;To solve this without Sass, I updated my build process. I swapped the Sass compiler for &lt;a href=&quot;https://bun.com/&quot; target=&quot;_blank&quot;&gt;Bun&lt;/a&gt;, which bundles and minifies my CSS imports into a single production-ready file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Build switch&lt;/strong&gt;:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;// From Sass:
execSync(`&quot;${sassBin}&quot; src/scss:dist --style=compressed`);

// To Bun:
execSync(`bun build ./src/css/${name} --outdir ./dist --minify`);
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#sass-mixins&quot; id=&quot;sass-mixins&quot;&gt;5. Mixins&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In this project I was using mixins for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reusable media queries&lt;/li&gt;
&lt;li&gt;Reusable shared styles&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Unfortunatelly &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Custom_functions_and_mixins&quot; target=&quot;_blank&quot;&gt;CSS mixins aren’t available yet&lt;/a&gt;, as at this point I was already decided to remove Sass, I decided to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Replace media query mixins to new media query syntax &lt;code&gt;@media (width &amp;gt;= 768px)&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Create utility classes for the shared styles.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To keep the final bundle clean, I used &lt;strong&gt;Lightning CSS&lt;/strong&gt; to group media queries and handle autoprefixing for older browsers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sass is officially gone&lt;/strong&gt;. While I miss the convenience of mixins, the combination of &lt;strong&gt;Modern CSS + Bun + Lightning CSS&lt;/strong&gt; gives me a faster and more &amp;quot;future-proof&amp;quot; workflow.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#was-it-worth-it&quot; id=&quot;was-it-worth-it&quot;&gt;Was it all worth it?&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here is the breakdown of this journey:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTML simplification&lt;/strong&gt;: Removing BEM resulted in cleaner, more readable HTML with significantly shorter class names.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Debugging clarity&lt;/strong&gt;: The source code and the browser’s executed code are nearly 1:1, making debugging much more intuitive.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Build performance&lt;/strong&gt;: Switching to Lightning CSS (Rust-based) provided near-instant build speeds compared to the Sass compiler.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Smaller bundles&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Before: 22.6 KB&lt;/li&gt;
&lt;li&gt;After: 16.68 KB (~26% reduction)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This refactor was a perfect opportunity to experiment with modern CSS features and tool consolidation. While this was a personal project where I could afford to be &amp;quot;bleeding edge&amp;quot;, every project has unique constraints. Decisions regarding browser support, team familiarity, and performance should always be made on a case-by-case basis.&lt;/p&gt;
&lt;p&gt;Ultimately, while modern CSS allows us to shed heavy tools, it doesn&#39;t eliminate the need for architectural decisions.&lt;/p&gt;
&lt;p&gt;I hope these insights help you decide which tools to keep, and which to leave behind, in your next project 🙂&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/articles/media-query-range-syntax&quot; target=&quot;_blank&quot;&gt; New syntax for range media queries - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ishadeed.com/article/css-nesting/&quot; target=&quot;_blank&quot;&gt; CSS Nesting -  Ahmad Shadeed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ishadeed.com/article/css-has-guide/&quot; target=&quot;_blank&quot;&gt; CSS :has() Interactive Guide -  Ahmad Shadeed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.smashingmagazine.com/2026/02/css-scope-alternative-naming-conventions/&quot; target=&quot;_blank&quot;&gt; CSS @scope: An Alternative To Naming Conventions And Heavy Abstractions - Smashing Magazine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>Using Chrome DevTools MCP to debug web accessibility</title>
        <link href="https://amandavilela.me/blog/using-chrome-devtools-mcp-to-debug-web-accessibility/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/using-chrome-devtools-mcp-to-debug-web-accessibility/</id>
        <published>2026-04-23T00:00:00.000Z</published>
        <updated>2026-04-23T00:00:00.000Z</updated>
        <summary>Learn how to set up the Chrome DevTools MCP Server with the Gemini CLI + Agent skills. Follow my walkthrough on using AI agent skills to debug web accessibility issues and automatically fix local code files.</summary>
        <category term="accessibility" />
        <content type="html" xml:base="https://amandavilela.me/blog/using-chrome-devtools-mcp-to-debug-web-accessibility/">&lt;p&gt;Chrome DevTools MCP Server enables a direct connection between your browser and AI coding assistants, providing real-time context of the active session and making debugging and fixes more accurate.&lt;/p&gt;
&lt;p&gt;In this post, I’ll walk through how to set up the Chrome DevTools MCP Server with the Gemini CLI + Agent Skills, and share my adventures using the tool to debug the accessibility of a travel website, then analyze a poorly structured local file and ask the tool to fix it. 🤠&lt;/p&gt;
&lt;nav aria-labelledby=&quot;toc-title&quot; class=&quot;table-of-contents&quot;&gt;
    &lt;h2 id=&quot;toc-title&quot;&gt;Table of Contents&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;a href=&quot;#install-chrome-devtools-mcp&quot;&gt;Installing Chrome DevTools MCP&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#installing-agent-skills&quot;&gt;Installing Agent Skills&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#debugging-accessibility&quot;&gt;Debugging accessibility&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;
                    &lt;a href=&quot;#lighthouse-accessibility-audits&quot;&gt;Lighthouse accessibility audits&lt;/a&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;a href=&quot;#asking-for-fixes&quot;&gt;Asking for fixes&lt;/a&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;a href=&quot;#dealing-with-non-semantic-markup&quot;&gt;Dealing with non-semantic markup&lt;/a&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;a href=&quot;#keyboard-testing&quot;&gt;Keyboard testing&lt;/a&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#running-chrome-devtools-mcp-locally&quot;&gt;Running Chrome DevTools MCP locally&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;#reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/nav&gt;
&lt;p&gt;First things first, what is MCP (Model Context Protocol)?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)—enabling them to access key information and perform tasks.
— &lt;a href=&quot;https://modelcontextprotocol.io/docs/getting-started/intro&quot; target=&quot;_blank&quot;&gt;Model Context Protocol docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Think of it like giving AI a pair of eyes and hands inside your browser.&lt;/p&gt;
&lt;p&gt;Now, with enough context, we can start testing the Chrome DevTools MCP Server capabilities.&lt;/p&gt;
&lt;section class=&quot;info-box disclaimer&quot;&gt;
    &lt;p&gt;This audit uses &lt;a href=&quot;https://www.momondo.com&quot; target=&quot;_blank&quot;&gt;www.momondo.com&lt;/a&gt; as a case study to explore the capabilities of the Chrome DevTools MCP Server for accessibility debugging. I picked Momondo both for its effective flight-search deals that I use regularly and for providing a perfect example of a complex, real-world UI.&lt;/p&gt;
    &lt;p&gt;The intention is not to evaluate the company or its teams, but to understand how the tool performs in practice.&lt;/p&gt;
&lt;/section&gt; 
&lt;h2&gt;&lt;a href=&quot;#install-chrome-devtools-mcp&quot; id=&quot;install-chrome-devtools-mcp&quot;&gt;Installing Chrome DevTools MCP&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To get started, you&#39;ll need an &lt;strong&gt;AI tool&lt;/strong&gt; on your terminal. Chrome DevTools MCP works with a &lt;a href=&quot;https://github.com/ChromeDevTools/chrome-devtools-mcp?tab=readme-ov-file#mcp-client-configuration&quot; target=&quot;_blank&quot;&gt;large range of clients&lt;/a&gt;, in this tutorial I&#39;m using &lt;a href=&quot;https://geminicli.com/&quot; target=&quot;_blank&quot;&gt;gemini-cli&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install gemini-cli&lt;/li&gt;
&lt;/ol&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;npm install -g @google/gemini-cli&lt;/code&gt;
&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Install the Chrome DevTools MCP server and add it to Gemini&#39;s list of MCP servers.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;gemini mcp add -s user chrome-devtools npx chrome-devtools-mcp@latest&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;&lt;a href=&quot;#testing-chrome-devtools-mcp-installation&quot; id=&quot;testing-chrome-devtools-mcp-installation&quot;&gt;Testing Chrome DevTools MCP installation&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To check if everything is working, run &lt;code&gt;gemini&lt;/code&gt; and &lt;strong&gt;interact with the MCP&lt;/strong&gt;&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;Open https://www.momondo.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Gemini detects that it needs to run &lt;code&gt;&amp;quot;new_page&amp;quot;&lt;/code&gt; from server ChromeDevTools MCP and ask will ask for permissions to run that.
Choosing &lt;strong&gt;Allow all server tools for this session&lt;/strong&gt; will save you from constant prompts during your session.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;mcp_new_page-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;365&quot;&gt;
    &lt;source srcset=&quot;mcp_new_page-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;mcp_new_page-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Execution of the Chrome DevTools MCP &quot;new_page&quot; tool for https://www.momondo.com, with options including &quot;Allow once&quot;, &quot;Allow tool for this session&quot;, and &quot;Allow all server tools for this session&quot;, the last option highlighted.&#39;&gt;
&lt;/picture&gt;
&lt;p&gt;On the first run, you&#39;ll be asked to &lt;strong&gt;login on your Google Account&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;You can then watch Gemini open a Chrome window and start following your commands:&lt;/p&gt;
&lt;figure&gt;
    &lt;video width=&quot;720&quot; height=&quot;362&quot; controls loading=&quot;lazy&quot;&gt;
        &lt;source src=&quot;mcp_test.mp4&quot; type=&quot;video/mp4&quot;&gt;
        &lt;source src=&quot;mcp_test.webm&quot; type=&quot;video/webm&quot;&gt;
        Your browser does not support the video tag.
    &lt;/video&gt;
    &lt;figcaption&gt;Gemini opens Chrome and uses DevTools MCP to open a new page automatically.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Once the page is open, the MCP should respond with something like: &lt;code&gt;The momondo homepage is now open. Would you like to search for a flight or do anything else?&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now that we’re set up, let’s add some &amp;quot;Agent Skills.&amp;quot;&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#installing-agent-skills&quot; id=&quot;installing-agent-skills&quot;&gt;Installing Agent Skills&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Agent Skills are packages containing instructions, and optional scripts that extend AI agent capabilities with specialized knowledge and workflows.&lt;/p&gt;
&lt;p&gt;We know AI coding agents are powerful but they usually optimize for &amp;quot;done&amp;quot; over &amp;quot;correct&amp;quot;, Agent Skills can be very helpful to avoid shortcuts, specially when analyzing code.&lt;/p&gt;
&lt;p&gt;In this post we are going to use &lt;a href=&quot;https://github.com/addyosmani/agent-skills&quot; target=&quot;_blank&quot;&gt;Addy Osmani Agent Skills&lt;/a&gt;, this package include 20 Skills that consolidate workflows, quality gates, and best practices that senior engineers use when building software, including accessibility skills, that will be relevant for this test.&lt;/p&gt;
&lt;p&gt;In order to add those skills, you can simply run on your terminal:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;gemini skills install https://github.com/addyosmani/agent-skills.git --path skills&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;To check if the skills were properly installed you can open gemini and run:&lt;/p&gt;
&lt;pre data-copy-code&gt;
&lt;code&gt;/skills list&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;a11y-debugging&lt;/strong&gt; should be the first item of the list this command returns.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#debugging-accessibility&quot; id=&quot;debugging-accessibility&quot;&gt;Debugging accessibility&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that have all the setup correct, let&#39;s take a deeper look on the &lt;strong&gt;accessibility features&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#lighthouse-accessibility-audits&quot; id=&quot;lighthouse-accessibility-audits&quot;&gt;Lighthouse accessibility audits&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I started by asking the MCP to perform a flight search and run an initial check.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;Can you make a search of flights to tokyo and run an accessibility check of the results page?
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it generates an report based on Lighthouse audit:&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;mcp_fix_issues_prompt-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;mcp_fix_issues_prompt-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;mcp_fix_issues_prompt-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&quot;Accessibility audit report generated by Gemini showing a list of detected issues.&quot;&gt;
    &lt;figcaption&gt;Gemini generated accessibility audit report highlighting issues.&lt;/figcaption&gt;
&lt;/picture&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the full Lighthouse audit&lt;/summary&gt;
    &lt;pre&gt;
        &lt;code&gt;✦ The accessibility check for the Momondo flight results page (Tokyo) is complete. The page received an Accessibility score of 83/100.
&lt;p&gt;Key Accessibility Issues Identified:&lt;/p&gt;
&lt;p&gt;1. Critical ARIA Misuse:
* Invalid Attributes: The &amp;quot;Cheapest,&amp;quot; &amp;quot;Best,&amp;quot; and &amp;quot;Quickest&amp;quot; sort buttons incorrectly use the aria-selected attribute, which is not permitted for the button role.
* Invalid Child Elements: The flight origin and destination &amp;quot;listbox&amp;quot; elements contain button roles as direct children, which violates ARIA standards (they should only contain option roles).&lt;/p&gt;
&lt;p&gt;2. Serious Contrast Issues:
* Multiple elements, including price labels (&amp;quot;$1,456&amp;quot;) and category headers (&amp;quot;Cheapest&amp;quot;), have a contrast ratio of ~2.63:1, falling well below the WCAG AA requirement of 4.5:1. This makes the text difficult to read for users with low vision.&lt;/p&gt;
&lt;p&gt;3. Labeling &amp;amp; Naming:
* Accessible Names: Several interactive elements, such as informational tooltips, lack accessible names, making them &amp;quot;unnamed&amp;quot; to screen readers.
* Name Mismatches: Visible text labels for locations (e.g., &amp;quot;Sao Paulo&amp;quot;) do not perfectly align with their programmatic accessible names, which can cause issues for voice control users.&lt;/p&gt;
&lt;p&gt;4. Role Inconsistencies:
* Radio roles are applied to label elements, and group roles are applied to link elements, which is non-standard and can confuse assistive technologies.&lt;/p&gt;
&lt;p&gt;Would you like a more detailed breakdown of any specific section, or should I help with something else?&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;h3&gt;&lt;a href=&quot;#asking-for-fixes&quot; id=&quot;asking-for-fixes&quot;&gt;Asking for fixes&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The report was concise, and the initial recommendations seemed reasonable at a glance. I followed up by asking for specific code fixes.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;How to fix those issues found? Can you point the exact items to fix?
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It returned a list with 6 detailed recommendations:&lt;/p&gt;
&lt;pre&gt;
    &lt;code&gt;&amp;#10022; To fix the accessibility issues found on the Momondo flight results page, you need to address specific ARIA role violations and color contrast failures. Here are the exact items to fix, along with the recommended code changes:
    
    1. Fix ARIA Attribute Misuse (Critical)
    The sort buttons (&amp;quot;Cheapest&amp;quot;, &amp;quot;Best&amp;quot;, &amp;quot;Quickest&amp;quot;) use attributes that aren&amp;#39;t allowed for their current roles.
    
    * Item: Sort Buttons (div.Hv20-option)
    * Current Issue: Uses role=&amp;quot;button&amp;quot; with aria-selected.
    * The Fix: Use aria-pressed instead of aria-selected for buttons that toggle state.
        * Bad: &amp;lt;div role=&amp;quot;button&amp;quot; aria-selected=&amp;quot;true&amp;quot;&amp;gt;Best&amp;lt;/div&amp;gt;
        * Fixed: &amp;lt;div role=&amp;quot;button&amp;quot; aria-pressed=&amp;quot;true&amp;quot;&amp;gt;Best&amp;lt;/div&amp;gt;
    
    2. Fix Invalid Component Structure (Critical)
    The location search fields violate the rule that a listbox can only contain option elements.
    
    * Item: Origin/Destination Inputs (div.vvTc)
    * Current Issue: The role=&amp;quot;listbox&amp;quot; container has a role=&amp;quot;button&amp;quot; (the &amp;quot;Add&amp;quot; button) as a direct child.
    * The Fix: Move the &amp;quot;Add&amp;quot; button outside the listbox or change the parent role to group.
        * Fixed: Change role=&amp;quot;listbox&amp;quot; to role=&amp;quot;group&amp;quot; or ensure only role=&amp;quot;option&amp;quot; elements are direct children.
    
    3. Fix Color Contrast (Serious)
    Several key pieces of information are hard to read for users with low vision because the text is too light.
    
    * Items:
        1. &amp;quot;Wait&amp;quot; label (div.IzNq-label-wait): Increase contrast of #e02472 on #21033a.
        2. Sort labels &amp;amp; prices (span in div.Hv20-title and div.Hv20-value): The color #a79bb0 on white is too light (2.63:1 ratio).
        3. Result descriptions (div.NAnQ-description): Also uses #a79bb0.
    * The Fix: Change the text color from #a79bb0 to a darker shade like #595959 or darker to reach the 4.5:1 contrast ratio.
    
    4. Fix Missing Accessible Names (Serious)
    Screen readers can&amp;#39;t identify what some buttons do because they have no text or labels.
    
    * Item: Information Tooltips (div.ftDe-trigger-wrapper and div.qQvr-wrapper)
    * Current Issue: No visible text and no aria-label.
    * The Fix: Add an aria-label describing the button&amp;#39;s purpose.
        * Fixed: &amp;lt;div role=&amp;quot;button&amp;quot; aria-label=&amp;quot;Flight details and amenities info&amp;quot; ...&amp;gt;&amp;lt;/div&amp;gt;
    
    5. Fix Invalid ARIA Roles
    Some elements are assigned roles that aren&amp;#39;t valid for their HTML tag.
    
    * Item: Filter Radios (label.c2jKu-label)
        * Issue: role=&amp;quot;radio&amp;quot; is assigned to a &amp;lt;label&amp;gt; element.
        * Fix: Put the role on the &amp;lt;input type=&amp;quot;radio&amp;quot;&amp;gt; itself and use the label normally (associated via for and id).
    * Item: Price Links (a.eNVa-link)
        * Issue: role=&amp;quot;group&amp;quot; is assigned to an &amp;lt;a&amp;gt; (anchor) tag.
        * Fix: Remove role=&amp;quot;group&amp;quot;. Anchors should naturally act as link roles.
    
    6. Fix Name Mismatches
    * Item: Location Buttons (div.vvTc-item)
    * Issue: The visible text &amp;quot;Sao Paulo&amp;quot; is inside an aria-label=&amp;quot;Flight origin input Sao Paulo&amp;quot;. This can fail for voice users who say &amp;quot;Click Sao Paulo.&amp;quot;
    * The Fix: Ensure the visible text matches or is at the start of the accessible name.
        * Fixed: Use aria-label=&amp;quot;Sao Paulo, Flight origin input&amp;quot; so the primary identifier is first.
    
    By addressing these specific elements, you will significantly improve the accessibility score and ensure the page is usable for people relying on screen readers, high contrast, or voice commands.&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Recommendations 3, 4, and 6 were spot on, but things got questionable with items 1, 2, and 5.
Let&#39;s see more details on the next section.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#dealing-with-non-semantic-markup&quot; id=&quot;dealing-with-non-semantic-markup&quot;&gt;Dealing with non-semantic markup&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I would like to start this with the &lt;a href=&quot;https://www.w3.org/TR/using-aria/#rule1&quot; target=&quot;_blank&quot;&gt;first rule of ARIA use&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Notice that the implementation suggestions rely a lot on adding or updating ARIA attributes, which is not wrong, but if we take a deeper look on the page markup, we notice that the HTML structure could be improved and that could result on a better accessibility.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#recommendation-1&quot; id=&quot;recommendation-1&quot;&gt;Recommendation 1&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;For recommendation 1 (swapping &lt;code&gt;aria-selected&lt;/code&gt; for &lt;code&gt;aria-pressed&lt;/code&gt;), we have a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; playing the role of a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;div_as_button-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;div_as_button-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;div_as_button-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Flight results page with &quot;Cheapest&quot;, &quot;Best&quot;, and &quot;Quickest&quot; options, alongside Chrome DevTools showing a highlighted element where a div with role=&quot;button&quot; and aria-selected=&quot;true&quot; is used instead of a native button.&#39;&gt;
&lt;/picture&gt;
&lt;p&gt;Instead of changing the ARIA attributes, it would be much simpler and more maintainable to just use a real &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; element. This gives you all the built-in accessibility for free.&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;#recommendation-2&quot; id=&quot;recommendation-2&quot;&gt;Recommendation 2&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Recommendation 2 suggested moving the &amp;quot;Add&amp;quot; button out of the listbox or changing the parent role to &amp;quot;group.&amp;quot; Let&#39;s break it into 2 parts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Moving the button outside the listbox makes sense as &lt;code&gt;listbox&lt;/code&gt; only accepts &lt;code&gt;option&lt;/code&gt; or &lt;code&gt;group&lt;/code&gt; as child roles. &lt;strong&gt;The first part of the recommendation is ok&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It also recommends to use the &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA17&quot; target=&quot;_blank&quot;&gt;group pattern&lt;/a&gt; instead of &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/patterns/listbox/&quot; target=&quot;_blank&quot;&gt;listbox&lt;/a&gt; for this component, however, &lt;code&gt;listbox&lt;/code&gt; is far more appropriate here than a generic group. &lt;strong&gt;The second part is not so accurate&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There is also a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; acting as the container for the &lt;code&gt;listbox&lt;/code&gt; trigger, implemented as a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; with &lt;code&gt;role=&amp;quot;button&amp;quot;&lt;/code&gt; that opens the listbox on click. This wasn’t mentioned in the audit, even though it has an invalid markup.&lt;/p&gt;
&lt;p&gt;A possible solution would be to use a native &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; element for the trigger and avoid coupling it with the listbox structure. Not calling this out makes the assessment feel incomplete.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;div_button_listbox-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;div_button_listbox-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;div_button_listbox-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Flight search form with origin and destination fields, alongside Chrome DevTools highlighting a div with role=&quot;button&quot; containing another role=&quot;button&quot;, and an element with role=&quot;listbox&quot;.&#39;&gt;
&lt;/picture&gt;
&lt;h4&gt;&lt;a href=&quot;#recommendation-5&quot; id=&quot;recommendation-5&quot;&gt;Recommendation 5&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;On recommendation 5 we also have &lt;strong&gt;2 fixes&lt;/strong&gt;, let&#39;s start with the &lt;strong&gt;first&lt;/strong&gt;: &amp;quot;Put the role on the &lt;code&gt;&amp;lt;input type=&amp;quot;radio&amp;quot;&amp;gt;&lt;/code&gt; itself and use the label normally (associated via for and id)&amp;quot;.&lt;/p&gt;
&lt;p&gt;This component is acts as a tab that switches the available options depending on the selection of &amp;quot;take-off&amp;quot; or &amp;quot;landing&amp;quot;, &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/patterns/tabs/&quot; target=&quot;_blank&quot;&gt;tabs pattern&lt;/a&gt; would work here, but I don&#39;t think it&#39;s an anti pattern using radio buttons implementation as it was made.&lt;/p&gt;
&lt;p&gt;It uses a custom radio button element, the suggested fix makes sense, but we don&#39;t need to add &lt;code&gt;role=&amp;quot;radio&amp;quot;&lt;/code&gt; to the &lt;code&gt;&amp;lt;input type=&amp;quot;radio&amp;quot;&amp;gt;&lt;/code&gt;, just removing the &lt;code&gt;role=&amp;quot;radio&amp;quot;&lt;/code&gt; from label is enough. &lt;strong&gt;Not a very accurate recommendation, again&lt;/strong&gt;.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;radio-buttons-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;radio-buttons-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;radio-buttons-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Flight filters panel with take-off and landing time options, alongside Chrome DevTools highlighting a radio input and label using role=&quot;radio&quot;, showing redundant ARIA on native form controls.&#39;&gt;
&lt;/picture&gt;
&lt;p&gt;The &lt;strong&gt;second recommendation&lt;/strong&gt; is about removing &lt;code&gt;role=&amp;quot;group&amp;quot;&lt;/code&gt; from a link, &lt;strong&gt;which makes total sense&lt;/strong&gt;.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;links_group-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;links_group-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;links_group-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Flight results page with a sponsored Expedia deal, alongside Chrome DevTools highlighting a link element with role=&quot;group&quot; and aria-label=&quot;Price details&quot;, indicating misuse of ARIA roles on a clickable link.&#39;&gt;
&lt;/picture&gt;
&lt;p&gt;Seeing these suggestions, I pushed back and asked if patching ARIA was really the best approach.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;given that html semantics are important to ensure accessibility. Does this page have a valid markup? Are the provided approaches the best solutions to fix those issues? Are there issues that can be fixed by improving the page semantics?
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This prompted a much more insightful response suggesting fixing the markup over updating/adding attributes ARIA.&lt;/p&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the full response&lt;/summary&gt;
    &lt;pre&gt;
        &lt;code&gt;&amp;#10022; The current markup on the Momondo flight results page relies heavily on &amp;lt;div&amp;gt; soup with ARIA roles rather than native HTML elements. While ARIA can make a &amp;lt;div&amp;gt; act like a button, it is a &amp;quot;polyfill&amp;quot; for poor semantics and often leads to the exact bugs I found in the audit.
&lt;p&gt;Here is an evaluation of the page&#39;s structural integrity and how improving semantics would provide better, more resilient fixes than just patching ARIA attributes.&lt;/p&gt;
&lt;p&gt;1. Is the current markup &amp;quot;Valid&amp;quot;?
Technically No. The audit highlights several spec violations:
* Structural Mismatch: A role=&amp;quot;listbox&amp;quot; containing a role=&amp;quot;button&amp;quot; is a direct violation of the ARIA structural model. A listbox is a managed container that should only contain option roles.
* Role Abuse: Placing role=&amp;quot;radio&amp;quot; on a &amp;lt;label&amp;gt; element is semantically incorrect. Labels are meant to describe inputs, not be the inputs.&lt;/p&gt;
&lt;p&gt;2. Are the previous fixes the &amp;quot;Best&amp;quot; solutions?
The previous fixes were &amp;quot;surgical patches&amp;quot; (fixing the ARIA to match the div structure). However, the best solution is almost always to replace the div with the correct native HTML element.&lt;/p&gt;
&lt;p&gt;Native elements have &amp;quot;built-in&amp;quot; accessibility that doesn&#39;t break when a developer forgets an attribute.&lt;/p&gt;
&lt;p&gt;3. Issues Fixed by Improving Semantics
By shifting from &amp;quot;ARIA-on-DIVs&amp;quot; to &amp;quot;Semantic HTML,&amp;quot; you fix multiple issues simultaneously:&lt;/p&gt;
&lt;p&gt;A. The Sort Buttons (Cheapest/Best/Quickest)
* Current: &amp;lt;div role=&amp;quot;button&amp;quot; aria-selected=&amp;quot;true&amp;quot;&amp;gt;
* Better Semantic Fix: Use a &amp;lt;button&amp;gt; or a Radio Group.
* Why: If these are mutualy exclusive options, they should be &amp;lt;input type=&amp;quot;radio&amp;quot;&amp;gt; elements styled to look like buttons.
* Result: You no longer need aria-selected or aria-pressed. Screen readers will automatically announce &amp;quot;Checked&amp;quot; or &amp;quot;Unchecked,&amp;quot; and keyboard navigation (arrow keys) is handled by the browser for free.&lt;/p&gt;
&lt;p&gt;B. The Filter Radios (Take-off/Landing)
* Current: &amp;lt;label role=&amp;quot;radio&amp;quot;&amp;gt;
* Better Semantic Fix: Use standard &amp;lt;input type=&amp;quot;radio&amp;quot;&amp;gt; with an associated &amp;lt;label&amp;gt;.
* Why: A native radio button handles its own checked state, focus management, and grouping.
* Result: Fixes the &amp;quot;ARIA role radio is not allowed for given element&amp;quot; error and ensures the state is correctly communicated without manual aria-checked updates.&lt;/p&gt;
&lt;p&gt;C. The Location Inputs (Sao Paulo/Tokyo)
* Current: div role=&amp;quot;listbox&amp;quot; containing div role=&amp;quot;button&amp;quot;
* Better Semantic Fix: Use a &amp;lt;datalist&amp;gt; or a Combobox pattern.
* Why: The &amp;quot;Add&amp;quot; button is currently trapped inside a container that tells screen readers &amp;quot;everything in here is a list option.&amp;quot;
* Result: Moving to a proper combobox structure separates the input, the list of suggestions, and the action buttons, resolving the structural violation.&lt;/p&gt;
&lt;p&gt;D. The &amp;quot;Unnamed&amp;quot; Tooltips
* Current: &amp;lt;div role=&amp;quot;button&amp;quot;&amp;gt; with an icon.
* Better Semantic Fix: Use a &amp;lt;button&amp;gt; with visually hidden text.
* Why: Instead of an aria-label (which can sometimes be ignored or misread), putting a &amp;lt;span&amp;gt; with a &amp;quot;visually-hidden&amp;quot; CSS class inside a real &amp;lt;button&amp;gt; tag is the gold standard.
* Result: Fixes the &amp;quot;Buttons do not have an accessible name&amp;quot; error and ensures the button is naturally focusable in the tab order.&lt;/p&gt;
&lt;p&gt;Summary: The &amp;quot;Semantics First&amp;quot; Rule
The most important rule in web accessibility is: &amp;quot;The best ARIA is no ARIA at all.&amp;quot;&lt;/p&gt;
&lt;p&gt;Conclusion: The current page is &amp;quot;over-engineered&amp;quot; with ARIA to compensate for a lack of semantic HTML. Replacing the interactive &amp;lt;div&amp;gt; elements with their native counterparts would resolve about 80% of the failed audits automatically.&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;It got confused with the buttons and divs soup, but overall, the debugging was &lt;strong&gt;better than browser Lighthouse&lt;/strong&gt;, which scored this page at 88 and only complained about icon buttons without labels.&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;lighthouse-audit-accessibility-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;346&quot;&gt;
    &lt;source srcset=&quot;lighthouse-audit-accessibility-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;lighthouse-audit-accessibility-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;A split-screen view of a web development audit. The left side displays a flight booking interface listing three travel options. The right side shows the Lighthouse accessibility audit panel with a score of 88/100. It displays an ARIA error stating that &quot;button, link, and menu item elements do not have accessible names&quot;.&#39;&gt;
    &lt;figcaption&gt;That&#39;s why we can&#39;t rely on Lighthouse only for accessibility&lt;/figcaption&gt;
&lt;/picture&gt;
&lt;h3&gt;&lt;a href=&quot;#keyboard-testing&quot; id=&quot;keyboard-testing&quot;&gt;Keyboard testing&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I also asked the MCP to perform a manual keyboard test, which revealed critical issues that automated audits often miss such as non-functional controls, unreachable content and inefficient tab order.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;Is it possible to run a proper keyboard test and identy issues?
&lt;/code&gt;&lt;/pre&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the keyboard audit&lt;/summary&gt;
    &lt;pre&gt;
        &lt;code&gt;&amp;#10022; I&amp;#39;ve identified that the &amp;quot;Show more results&amp;quot; button is reachable with &amp;quot;Tab,&amp;quot; which is a good sign for keyboard accessibility. I&amp;#39;ll now summarize my findings from the keyboard test.
&lt;p&gt;Additional Keyboard Accessibility Issues Found:&lt;/p&gt;
&lt;p&gt;1. Non-Functional Controls (Critical):
* Filter Switches (INPUT role=&amp;quot;switch&amp;quot;): These elements do not toggle when pressing &amp;quot;Space&amp;quot; or &amp;quot;Enter.&amp;quot; A keyboard user is effectively locked out of using these filters.&lt;/p&gt;
&lt;p&gt;2. Unreachable Content (Serious):
* Flight Result Cards: The cards themselves have tabindex=&amp;quot;-1&amp;quot;. While the &amp;quot;Select&amp;quot; button inside is reachable, the card structure (which often contains click-to-expand details) is not natively focusable.&lt;/p&gt;
&lt;p&gt;3. Inefficient Tab Order:
* The &amp;quot;Location&amp;quot; fields (Sao Paulo, Tokyo) require multiple tab presses to get past (Container -&amp;gt; Option -&amp;gt; Remove -&amp;gt; Add). This makes navigating the header very tedious for power users.&lt;/p&gt;
&lt;p&gt;4. Inconsistent Focus Indicators:
* While focus moves between elements, some div role=&amp;quot;button&amp;quot; elements lack a clearly visible focus ring in their default state, making it hard to know exactly where the focus is without a screen reader.&lt;/p&gt;
&lt;p&gt;5. Native Element Abuse:
* The &amp;quot;Show more results&amp;quot; button is a &amp;lt;div&amp;gt; with role=&amp;quot;button&amp;quot; and tabindex=&amp;quot;0&amp;quot;. While it works, using a native &amp;lt;button&amp;gt; would be more robust as it handles &amp;quot;Enter&amp;quot; and &amp;quot;Space&amp;quot; activation automatically.&lt;/p&gt;
&lt;p&gt;Would you like me to focus on fixing one of these specific keyboard interactions?&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;I noticed it didn&#39;t interact with many components on the page, so I asked it to test more components, such as the date picker and the airline filters, and it returned:&lt;/p&gt;
&lt;details&gt;
    &lt;summary&gt;Click here to see the components audit&lt;/summary&gt;
    &lt;pre&gt;
        &lt;code&gt;&amp;#10022; I&amp;#39;ve conducted extensive accessibility testing on the flight results page, focusing on keyboard navigation and semantic markup. Here&amp;#39;s a summary of my findings:
&lt;p&gt;1. Date Picker Accessibility (Critical)
* Reachability Issues: The main &amp;quot;Departure date&amp;quot; and &amp;quot;Return date&amp;quot; buttons have tabindex=&amp;quot;-1&amp;quot;, which prevents them from being reached via standard keyboard navigation. While the dates themselves are reachable, the &amp;quot;Date arrows&amp;quot; (increment/decrement buttons) are also inaccessible.
* Interaction Failure: Even when focusing the date div and pressing &amp;quot;Enter,&amp;quot; the calendar fails to open, effectively locking out keyboard users from modifying their travel dates.&lt;/p&gt;
&lt;p&gt;2. Airline Filters Accessibility (Serious)
* Non-Standard Markup: The airline checkboxes and filter controls are implemented as &amp;lt;div&amp;gt; elements with role=&amp;quot;button&amp;quot; or tabindex=&amp;quot;0&amp;quot;, rather than native &amp;lt;input type=&amp;quot;checkbox&amp;quot;&amp;gt; elements.
* Functional Barrier: The airline checkboxes fail to toggle when the &amp;quot;Space&amp;quot; or &amp;quot;Enter&amp;quot; keys are pressed, preventing keyboard users from filtering by airline.&lt;/p&gt;
&lt;p&gt;3. Price Alert Modal (UX Issue)
* Trap &amp;amp; Trigger: Pressing &amp;quot;Enter&amp;quot; on a results page can trigger the &amp;quot;Price Alert&amp;quot; modal unexpectedly. Once open, the modal&#39;s &amp;quot;Close&amp;quot; button is difficult to reach via the keyboard, and the &amp;quot;Escape&amp;quot; key doesn&#39;t reliably close it, creating a &amp;quot;keyboard trap.&amp;quot;&lt;/p&gt;
&lt;p&gt;4. Overall Markup Observations
* &amp;quot;DIV Soup&amp;quot;: The page relies heavily on generic &amp;lt;div&amp;gt; elements with ARIA roles and manual tabindex management, which is more prone to bugs and inconsistent behavior than using native HTML elements.
* Missing Semantic Cues: The lack of native form elements (buttons, checkboxes, radios) makes the page less intuitive for assistive technology and more difficult to navigate for keyboard-only users.&lt;/p&gt;
&lt;p&gt;Recommended Fixes (Prioritized):
1. Replace &amp;lt;div&amp;gt; buttons/checkboxes with native &amp;lt;button&amp;gt; and &amp;lt;input type=&amp;quot;checkbox&amp;quot;&amp;gt; to restore standard keyboard functionality and ARIA compatibility.
2. Ensure all interactive elements are in the natural tab order (removing tabindex=&amp;quot;-1&amp;quot; from primary controls).
3. Implement proper &amp;quot;Escape&amp;quot; key handling for modals and ensure they are reachable and closable via the keyboard.&lt;/p&gt;
&lt;p&gt;Would you like me to focus on fixing a specific component, or is there another part of the page you&#39;d like me to audit?&lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;This part of the audit was insightful and highlighted the tool&#39;s real value as a debugging &amp;quot;sidekick.&amp;quot;&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#running-chrome-devtools-mcp-locally&quot; id=&quot;running-chrome-devtools-mcp-locally&quot;&gt;Running Chrome DevTools MCP locally&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Finally, I decided to test its ability to fix code directly. I created a purposefully broken HTML file and asked it to fix the accessibility issues locally.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;poorly_accessible_flight_search.html&quot; download&gt;Download the broken file&lt;/a&gt;.&lt;/p&gt;
&lt;pre data-copy-code&gt;&lt;code&gt;What change would you make to fix the accessibility of the flight_search.html file? You can edit the file locally
&lt;/code&gt;&lt;/pre&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;mcp_local_file_change-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;365&quot;&gt;
    &lt;source srcset=&quot;mcp_local_file_change-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;mcp_local_file_change-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&#39;Terminal displaying an &quot;Action Required&quot; prompt to apply a code change in a file named flight_search.html. A menu lists options for accepting the changes, including &quot;Allow once,&quot; &quot;Allow for this session,&quot; &quot;Modify with external editor,&quot; and &quot;No, suggest changes&#39;&gt;
    &lt;figcaption&gt;Before Gemini edits files, you&#39;ll need to approve that.&lt;/figcaption&gt;
&lt;/picture&gt;
&lt;p&gt;It updated the file with fixes. &lt;a href=&quot;flight_search_fixed.html&quot; download&gt;Download the fixed file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The agent refactored the file, replacing generic &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags with semantic elements like &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;. It also fixed contrast issues and added proper &lt;code&gt;aria-labels&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Although my file was very simple and had obvious accessibility improvements, I think the fixes suggested were reliable.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#final-thoughts&quot; id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chrome DevTools MCP Server + Gemini CLI + Agent Skills were useful for spotting odd or problematic accessibility cases on the page. It’s particularly good at identifying keyboard navigation failures that static analysis misses.&lt;/p&gt;
&lt;p&gt;However, the quality of its fix suggestions is still inconsistent. In the case of the buttons, for example, it recommended adding ARIA attributes, which is not incorrect, but it wasn’t appropriate for that page, where the real issue was poor semantics. Despite having browser context, it wasn’t able to fully understand some custom components, such as the listbox and the tabs. This led to accessibility suggestions that weren’t entirely wrong, but could have been resolved with simpler markup.&lt;/p&gt;
&lt;p&gt;This test aligns with recent research from &lt;a href=&quot;https://embrace.io/guides/ai-observability-gap-report/&quot; target=&quot;_blank&quot;&gt;Embrace&lt;/a&gt;, showing that while developers are comfortable using AI for &lt;strong&gt;building&lt;/strong&gt;, they are still hesitant to fully trust its explanations for &lt;strong&gt;why&lt;/strong&gt; things are broken.&lt;/p&gt;
&lt;p&gt;One open question is whether plugin a more code-focused agent, such as &lt;a href=&quot;https://claude.ai/&quot; target=&quot;_blank&quot;&gt;Claude&lt;/a&gt; on Chrome DevTools MCP, would produce more robust results in this kind of analysis. This is something worth exploring further to understand how different AI tools perform in accessibility and debugging workflows.&lt;/p&gt;
&lt;p&gt;Is it ready to replace a manual audit? Not quite. Is it a good tool for spotting issues and facilitate keyboard testing? Absolutely! The tool is more effective as an exploratory and debugging aid than as a reliable source of solutions. It can guide your attention, but it still requires a critical eye to interpret and validate its recommendations, even so, I see a lot of potential and I&#39;m curious to see how this evolves.&lt;/p&gt;
&lt;p&gt;I intend to continue using these tools in future case studies and accessibility audits. I recommend you do the same, as the Chrome DevTools MCP receives frequent updates and AI agents continue to advance.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.a11y-collective.com/blog/aria-in-html/&quot; target=&quot;_blank&quot;&gt;Implementing ARIA: Avoid Common Pitfalls and Optimise Performance - a11y collective&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>Why your UI feels slow: A Practical guide to INP</title>
        <link href="https://amandavilela.me/blog/your-page-is-fast-but-is-it-responsive-meet-inp/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/your-page-is-fast-but-is-it-responsive-meet-inp/</id>
        <published>2026-04-14T00:00:00.000Z</published>
        <updated>2026-04-14T00:00:00.000Z</updated>
        <summary>Page load time is not enough, learn about Interaction to Next Paint metric and how to improve it.</summary>
        <category term="core web vitals" />
        <content type="html" xml:base="https://amandavilela.me/blog/your-page-is-fast-but-is-it-responsive-meet-inp/">&lt;p&gt;Web performance goes beyond loading speed, it also depends on how quickly the page responds to user interactions.&lt;/p&gt;
&lt;p&gt;This is exactly what &lt;strong&gt;Interaction to Next Paint (INP)&lt;/strong&gt; measures.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#what-is-inp&quot; id=&quot;what-is-inp&quot;&gt;What is INP?&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/articles/inp&quot; target=&quot;_blank&quot;&gt;INP (Interaction to Next Paint)&lt;/a&gt; is one of the 3 &lt;a href=&quot;https://developers.google.com/search/docs/appearance/core-web-vitals&quot; target=&quot;_blank&quot;&gt;Core Web Vitals metrics&lt;/a&gt; and captures the delay between a user interaction (like a click or tap) and the next visual update on the screen.&lt;/p&gt;
&lt;p&gt;A good INP is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;≤ 200ms&lt;/strong&gt; → good&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;200–500ms&lt;/strong&gt; → needs improvement&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;gt; 500ms&lt;/strong&gt; → poor&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In practice, even small delays can significantly impact how responsive a product feels, especially in interaction-heavy interfaces. The uncertainty and frustration about whether the action worked often lead users to make repeated clicks or abandon tasks.&lt;/p&gt;
&lt;p&gt;Once a page is loaded, the browser still has work to do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;calculating styles&lt;/li&gt;
&lt;li&gt;running JavaScript&lt;/li&gt;
&lt;li&gt;updating layout&lt;/li&gt;
&lt;li&gt;rendering changes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If that work is too heavy, interactions get delayed.
From the user’s perspective, this feels like lag, even if the page “loaded fast”.&lt;/p&gt;
&lt;p&gt;In this context, &lt;strong&gt;reducing browser work&lt;/strong&gt; becomes key to improving responsiveness.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#quick-guide-to-improve-inp&quot; id=&quot;quick-guide-to-improve-inp&quot;&gt;Quick guide to improve INP&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Below I selected a list of tweaks that can help improve INP metric prioritized by level of effort to implement:&lt;/p&gt;
&lt;picture&gt;
    &lt;source srcset=&quot;inp-960w.webp&quot; media=&quot;(min-width: 640px)&quot; height=&quot;365&quot;&gt;
    &lt;source srcset=&quot;inp-640w.webp&quot; media=&quot;(min-width: 320px)&quot; height=&quot;237&quot;&gt;
    &lt;img src=&quot;inp-320w.webp&quot; width=&quot;300&quot; height=&quot;151&quot; loading=&quot;lazy&quot; alt=&quot;PageSpeed Insights report showing a failed Core Web Vitals assessment: LCP 2.3 s and CLS 0.01 are good, but INP is 418 ms, in the needs-improvement range.&quot;&gt;
&lt;/picture&gt;
&lt;h3&gt;&lt;a href=&quot;#reduce-dom-size&quot; id=&quot;reduce-dom-size&quot;&gt;1. Reduce DOM size&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Large DOM trees increase the cost of almost everything the browser does.&lt;/p&gt;
&lt;p&gt;Every interaction can trigger:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;style recalculations&lt;/li&gt;
&lt;li&gt;layout updates&lt;/li&gt;
&lt;li&gt;paint operations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As a rule, &lt;strong&gt;keeping the DOM under ~1500 nodes&lt;/strong&gt; helps maintain better performance.&lt;/p&gt;
&lt;p&gt;Common issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;deeply nested structures&lt;/li&gt;
&lt;li&gt;unnecessary wrappers&lt;/li&gt;
&lt;li&gt;rendering large lists all at once&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a href=&quot;#use-content-visibility&quot; id=&quot;use-content-visibility&quot;&gt;2. Use content-visibility: auto&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Speaking of large DOMs, if you can’t remove elements, you can hide them from the browser’s initial radar with &lt;code&gt;content-visibility&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;content-visibility&lt;/code&gt; CSS property allows the browser to skip rendering content that is outside the viewport.
This means &lt;strong&gt;less work during initial load&lt;/strong&gt; and &lt;strong&gt;less work during interactions&lt;/strong&gt;, it’s especially useful for long pages and content-heavy layouts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To avoid negatively impact accessibility or SEO&lt;/strong&gt;, provide a placeholder size (for example, using &lt;code&gt;contain-intrinsic-size&lt;/code&gt;), so the browser can reserve space for the element and prevent &lt;a href=&quot;https://web.dev/articles/cls&quot; target=&quot;_blank&quot;&gt;Cumulative Layout Shift (CLS)&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#careful-with-inline-svgs&quot; id=&quot;careful-with-inline-svgs&quot;&gt;3. Be careful with inline SVGs&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Inline SVGs can be a great optimization because they avoid additional HTTP requests. However, they also increase DOM size.&lt;/p&gt;
&lt;p&gt;Each SVG becomes part of the DOM tree, adding to the overall rendering cost, &lt;strong&gt;reserve inline SVGs for essential&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#use-transfor-and-opacity-for-animations&quot; id=&quot;use-transfor-and-opacity-for-animations&quot;&gt;4. Use transform and opacity for animations&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Prefer &lt;code&gt;transform&lt;/code&gt; and &lt;code&gt;opacity&lt;/code&gt; for animations triggered by user interactions, as they avoid layout recalculations or repaints in the browser.&lt;/p&gt;
&lt;p&gt;Avoid using animating properties like width, height, or top/left.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#avoid-forced-synchronous-layouts&quot; id=&quot;avoid-forced-synchronous-layouts&quot;&gt;5. Avoid forced synchronous layouts (layout thrashing)&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Layout thrashing happens when DOM reads and writes are interleaved, forcing the browser to recalculate layout multiple times during an interaction.&lt;/p&gt;
&lt;p&gt;Modern browsers try to batch updates for efficiency, however, this optimization breaks when layout information is requested immediately after a change.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;
element.style.width = &quot;100px&quot;;  // write
element.offsetHeight;           // read =&gt; forces layout
&lt;/pre&gt;
&lt;p&gt;Each read requires an up-to-date layout, so the browser is forced to recalculate it synchronously. Avoid forcing synchronous layouts by &lt;strong&gt;separating DOM reads and writes&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Properties such as &lt;code&gt;offsetHeight&lt;/code&gt;, &lt;code&gt;offsetWidth&lt;/code&gt;, &lt;code&gt;getBoundingClientRect()&lt;/code&gt; and &lt;code&gt;scrollTop&lt;/code&gt; can trigger layout calculations, so they should be used carefully during interactions.&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#debounce-throttle-event-handlers&quot; id=&quot;debounce-throttle-event-handlers&quot;&gt;6. Debounce/throttle event handlers&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Events like: &lt;code&gt;scroll&lt;/code&gt;, &lt;code&gt;input&lt;/code&gt;, &lt;code&gt;resize&lt;/code&gt; and &lt;code&gt;typing&lt;/code&gt; can be triggered dozens of times per second, this can easily turns into long tasks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Debounce&lt;/strong&gt; pauses execution until events stop for a specified time (ideal for search inputs), while &lt;strong&gt;throttle&lt;/strong&gt; limits execution to once every specified interval (ideal for scroll tracking).&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;#be-mindful-of-third-party-scripts&quot; id=&quot;be-mindful-of-third-party-scripts&quot;&gt;7. Be mindful of third-party scripts&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Even if your own code is optimized, third-party scripts often aren’t.&lt;/p&gt;
&lt;p&gt;JavaScript runs on the main thread. Long tasks block the browser from responding to user input, making them a common cause of poor INP.&lt;/p&gt;
&lt;p&gt;Common offenders:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;analytics tools&lt;/li&gt;
&lt;li&gt;chat widgets&lt;/li&gt;
&lt;li&gt;A/B testing scripts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Review what’s running on your page and prioritize what truly matters.&lt;/p&gt;
&lt;p&gt;When possible, defer non-critical work using strategies such as &lt;code&gt;requestIdleCallback()&lt;/code&gt;, so scripts execute during idle periods instead of competing with user interactions.&lt;/p&gt;
&lt;p&gt;Server side tagging are also a good solution to significantly reduce client-side overhead, depending on your setup.
Google Tag Manager offers a &lt;a href=&quot;https://developers.google.com/tag-platform/tag-manager/server-side&quot; target=&quot;_blank&quot;&gt;server-side option&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#final-thoughts&quot; id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Most performance issues aren’t caused by a single problem, but by multiple small decisions accumulating over time.&lt;/p&gt;
&lt;p&gt;Improving INP often means choosing between competing priorities, like delaying scripts, simplifying UI, or reducing functionality.&lt;/p&gt;
&lt;p&gt;You won’t improve INP with isolated optimizations, &lt;strong&gt;every decision has a cost&lt;/strong&gt;, what looks like a good solution may not hold in the context of the full system.&lt;/p&gt;
&lt;p&gt;Understanding those trade-offs, and making decisions based on real constraints, is what leads to consistently responsive interfaces.&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;#reading-recommendations&quot; id=&quot;reading-recommendations&quot;&gt;Reading recommendations&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/articles/optimize-long-tasks&quot; target=&quot;_blank&quot;&gt;Optimize long tasks - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing&quot; target=&quot;_blank&quot;&gt;Avoid large, complex layouts and layout thrashing - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/articles/animations-guide&quot; target=&quot;_blank&quot;&gt;How to create high-performance CSS animations - web.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://love-coding.pl/en/optimizing-events-in-javascript-debounce-and-throttle&quot; target=&quot;_blank&quot;&gt;Optimizing events in JavaScript: debounce and throttle - Love Coding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility&quot; target=&quot;_blank&quot;&gt;content-visibility - MDN&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry>
        <title>Hello World</title>
        <link href="https://amandavilela.me/blog/hello-world/" rel="alternate" type="text/html" />
        <id>https://amandavilela.me/blog/hello-world/</id>
        <published>2026-04-09T00:00:00.000Z</published>
        <updated>2026-04-09T00:00:00.000Z</updated>
        <summary>Who am I and what to expect from this blog</summary>
        <content type="html" xml:base="https://amandavilela.me/blog/hello-world/">&lt;p&gt;I’m a Brazilian frontend engineer, officially in the industry since 2012, although my journey on the web started a bit earlier, when I was following tutorials to customize my &lt;a href=&quot;https://www.blogger.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Blogspot&lt;/a&gt; layout. That’s where my interest in the internet began.&lt;/p&gt;
&lt;p&gt;A few years later, I joined a technical course focused on web development, where I learned the fundamentals and realized that building websites could actually be a career. Soon after, I started my first job as an intern, and I haven’t stopped working with frontend since.&lt;/p&gt;
&lt;p&gt;Throughout this journey, I’ve worked at agencies, large corporations, as a freelancer, and at mid-sized companies. I’ve also contributed to the tech community through &lt;a href=&quot;https://speakerdeck.com/amandavilela&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;talks&lt;/a&gt;, workshops, and by organizing events to support and grow my local community, helping more people find their path into tech.&lt;/p&gt;
&lt;p&gt;I dedicated a good time of career on shipping interfaces, making things work, making them look right, and meeting deadlines. Over time, I became more interested in what happens beyond the surface: performance bottlenecks, accessibility gaps, and the hidden cost of decisions that seem harmless at first.&lt;/p&gt;
&lt;p&gt;In my latest role, I had the opportunity to influence how products were built, advocating for performance optimization and accessibility improvements, and later leading teams and guiding technical decisions at a broader level.&lt;/p&gt;
&lt;p&gt;In 2025, I took a step back from work. Not as a break from the industry, but as an intentional pause to reflect, study, and rethink what I want to build and contribute next.&lt;/p&gt;
&lt;p&gt;I studied piano, traveled, and maybe most importantly, learned how to do nothing. Even so, I never fully disconnected from the industry, I kept following how the web is evolving and how new ideas are shaping the way we build for it. It was an important moment.&lt;/p&gt;
&lt;p&gt;In March 2026, I was invited to speak at Faculdade de Tecnologia de Sorocaba, the university where I studied, for an International Women’s Day event. This is something I’ve always done with care and genuine interest, but this time felt different after being away from the industry for a while.&lt;/p&gt;
&lt;p&gt;While talking to first-year students, encouraging them and sharing my experience, I found myself remembering why I liked tech in the first place. It’s easy to lose sight of that over time.&lt;/p&gt;
&lt;p&gt;Since then, I’ve been &lt;em&gt;slowly getting back into it&lt;/em&gt; and &lt;em&gt;preparing the ground for what comes next&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Redesigning and refactoring my portfolio, and now starting this blog, are part of that process. I’ve always wanted to have a blog again, but never prioritized it or found the time. After this break, I’m finally able to enjoy the process of building it.&lt;/p&gt;
&lt;p&gt;Here, you’ll find a mix of short reflections and deeper dives, sometimes practical, sometimes critical, always grounded in real experience.&lt;/p&gt;
&lt;p&gt;Nice to meet you, and I hope to see you in the next post 🤝🙂&lt;/p&gt;
</content>
    </entry>
</feed>
