frontend-dom

frontend-dom is a command for coding agents from JoasASantos/ClaudeAdvancedPlugins. It costs 0 tokens per session (2,002 once invoked), scanned A, original, MIT.

A guide to changing web pages through the browser's Document Object Model, the browser's in-memory representation of HTML. It covers browser APIs, Web Components, and client-side code that runs in the browser.

In plain words
What is it for?
Use it when building or tuning interactive web interfaces, custom elements, browser-based updates, and DOM-heavy client-side code.
Why use it?
It helps avoid slow page updates and layout problems caused by repeatedly changing and measuring page elements in the wrong order.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/joasasantos/claudeadvancedplugins/frontend-dom
Clone the repo
git clone --depth 1 https://github.com/JoasASantos/ClaudeAdvancedPlugins

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for frontend-dom

README.md
[![agentmods](https://agentmods.dev/badge/commands/joasasantos/claudeadvancedplugins/frontend-dom.svg)](https://agentmods.dev/commands/joasasantos/claudeadvancedplugins/frontend-dom)
Your own site
<a href="https://agentmods.dev/commands/joasasantos/claudeadvancedplugins/frontend-dom"><img src="https://agentmods.dev/badge/commands/joasasantos/claudeadvancedplugins/frontend-dom.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,002 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02002
Opus 5 $0.00000 $0.01001
Sonnet 5 $0.00000 $0.00400
Haiku 4.5 $0.00000 $0.00200

Measured 4d ago against content hash 4f83c8df921f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

frontend-dom scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/frontend-dom/commands/frontend-dom.md · 319 lines

How it starts

The opening of the file, as written. The whole thing — 319 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Frontend DOM Mastery Plugin

You are an expert in DOM manipulation, browser APIs, Web Components, and advanced client-side engineering.

DOM Deep Dive

DOM Manipulation Performance

Batch DOM Operations:

// BAD: Multiple reflows
items.forEach(item => {
  container.appendChild(createNode(item)); // Reflow each time
});

// GOOD: Document Fragment (single reflow)
const fragment = document.createDocumentFragment();
items.forEach(item => fragment.appendChild(createNode(item)));
container.appendChild(fragment);

// GOOD: innerHTML batch (single parse + reflow)
container.innerHTML = items.map(item => `<div>${item}</div>`).join('');

// BEST: requestAnimationFrame for visual updates
requestAnimationFrame(() => {
  element.style.transform = `translateX(${x}px)`;
});

Layout Thrashing Prevention:

// BAD: Read-write interleaving (causes forced synchronous layout)
elements.forEach(el => {
  const height = el.offsetHeight;    // READ (forces layout)
  el.style.height = height + 10;     // WRITE (invalidates layout)
});

// GOOD: Batch reads, then batch writes
const heights = elements.map(el => el.offsetHeight); // All READs
elements.forEach((el, i) => {
  el.style.height = heights[i] + 10; // All WRITEs
});

// BEST: Use ResizeObserver for size-dependent logic
const observer = new ResizeObserver(entries => {
  for (const entry of entries) {
    const { width, height } = entry.contentRect;
    // React to size changes without triggering layout
  }
});

Virtual DOM & Reconciliation

  • React Fiber reconciliation algorithm
  • Key-based diffing optimization
  • Concurrent rendering and Suspense
  • Vue 3 proxy-based reactivity
  • Svelte compile-time optimization (no virtual DOM)
  • Solid.js fine-grained reactivity
  • DOM recycling in virtual lists

Shadow DOM & Web Components

class AdvancedComponent extends HTMLElement {
  #shadowRoot;
  #internals;

  static get observedAttributes() {
    return ['variant', 'size', 'disabled'];
  }

  constructor() {
    super();
    this.#shadowRoot = this.attachShadow({ mode: 'open' });
    this.#internals = this.attachInternals();
    // Form-associated custom element
    this.#internals.setFormValue('');
  }

  connectedCallback() {
    this.render();
    this.#setupEventListeners();
    this.#setupA11y();
  }

  disconnectedCallback() {
    this.#cleanup();
  }

  adoptedCallback() {
    // Moved to new document
  }

  attributeChangedCallback(name, oldVal, newVal) {
    if (oldVal !== newVal) this.render();
  }

  render() {
    this.#shadowRoot.innerHTML = `
      <style>
        :host { display: block; contain: content; }
        :host([hidden]) { display: none; }
        :host(:focus-within) { outline: 2px solid var(--focus-color, blue); }
        ::slotted(*) { /* style slotted content */ }
        .internal { /* scoped styles */ }
      </style>
      <div class="internal" part="container">
        <slot name="header"></slot>
        <slot></slot>
        <slot name="footer"></slot>
      </div>
    `;
  }

  // CSS Custom Properties API
  static get styles() {
    return `
      :host {
        --component-bg: var(--theme-bg, #fff);
        --component-color: var(--theme-color, #000);
      }
    `;
  }

  #setupA11y() {
    this.setAttribute('role', 'region');
    this.#internals.ariaLabel = 'Component label';
    this.#internals.states?.add('--loading');
  }
}

// Register with declarative shadow DOM support
customElements.define('advanced-component', AdvancedComponent);

Read the full file on GitHub · 319 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 319 lines · 0 tokens per session scan A 4f83c8df921f

Subscribe to this mod's changes

frontend-dom is a command published in the GitHub repository JoasASantos/ClaudeAdvancedPlugins (154 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,002 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.