dom-manipulation-best-practices

dom-manipulation-best-practices is a cursor rule for Cursor from adobecom/da-express-milo. It costs 2,921 tokens per session, scanned A, original, Apache-2.0.

A set of rules for changing a web page's document structure, the browser's in-memory representation of the page. It divides work into eager, lazy, and delayed phases, with special attention to the content that appears first.

In plain words
What is it for?
It guides developers when creating or enhancing page elements, especially above-the-fold content and changes that can be loaded after the initial page display.
Why use it?
It helps avoid making the page feel slow by limiting immediate work and postponing nonessential changes. It focuses on keeping the largest visible content, called LCP, quick to appear.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It guides developers when creating or enhancing page elements, especially above-the-fold content and changes that can be loaded after the initial page display.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/adobecom/da-express-milo/dom-manipulation-best-practices
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.

Clone the repo
git clone --depth 1 https://github.com/adobecom/da-express-milo

Made for: Cursor.

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 dom-manipulation-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/adobecom/da-express-milo/dom-manipulation-best-practices.svg)](https://agentmods.dev/rules/adobecom/da-express-milo/dom-manipulation-best-practices)
Your own site
<a href="https://agentmods.dev/rules/adobecom/da-express-milo/dom-manipulation-best-practices"><img src="https://agentmods.dev/badge/rules/adobecom/da-express-milo/dom-manipulation-best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,921 This file is loaded in full into every session.
When invoked 2,921 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.02921 $0.02921
Opus 5 $0.01460 $0.01460
Sonnet 5 $0.00584 $0.00584
Haiku 4.5 $0.00292 $0.00292

Measured 7d ago against content hash d8aad088f48d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

dom-manipulation-best-practices 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 7d 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/dom-manipulation-best-practices.mdc · 449 lines

How it starts

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

DOM Manipulation Performance Rules - Three-Phase Strategy

APPLY: EVERY QUERY - CRITICAL PERFORMANCE RULE

AEM Performance Principles (REQUIRED)

Based on AEM's performance guidelines:

  • Phase E (Eager): Minimal DOM creation for LCP elements only
  • Phase L (Lazy): Progressive enhancement of below-fold content
  • Phase D (Delayed): Third-party DOM modifications after 3+ second delay

Phase E - LCP Critical DOM Operations (REQUIRED)

Immediate DOM insertion for LCP elements, minimal complexity

// ✅ REQUIRED - Phase E: Simple DOM structure for LCP
const createLCPElement = (content) => {
  const isFirstSection = true; // Determining logic for first section
  
  if (isFirstSection) {
    // Phase E: Keep DOM structure minimal for LCP
    const el = createTag('div', { class: 'hero-content' });
    el.textContent = content; // Simple text content first
    
    // Return immediately for LCP
    return el;
  }
};

// ✅ REQUIRED - Progressive enhancement pattern
const enhanceLCPElement = (element, enhancementData) => {
  // Phase L: Add enhancements after LCP
  setTimeout(() => {
    const enhancedContent = createTag('div', { class: 'enhanced-content' });
    enhancedContent.innerHTML = enhancementData;
    element.appendChild(enhancedContent);
  }, 0);
};

createElement Pattern (REQUIRED)

Always use the standardized createTag pattern from utils.js:

// ✅ CORRECT - Preserves events and performance (all phases)
const el = createTag('div', { class: 'my-class' }, content);
parent.append(el);

// ❌ WRONG - Breaks event listeners and re-parses DOM  
parent.innerHTML = '<div class="my-class">content</div>';

Phase-Aware DOM Construction (REQUIRED)

// ✅ REQUIRED - Build DOM progressively by phase
class ComponentBuilder {
  constructor(element) {
    this.element = element;
    this.isFirstSection = element.closest('.section') === document.querySelector('.section');
  }
  
  init() {
    if (this.isFirstSection) {
      // Phase E: Critical structure only
      this.buildCriticalDOM();
    } else {
      // Phase L: Build with intersection observer
      this.buildWithLazyLoading();
    }
  }
  
  buildCriticalDOM() {
    // Phase E: Minimal DOM for LCP
    const basicStructure = this.createBasicStructure();
    this.element.appendChild(basicStructure);
    
    // Queue enhancements for Phase L
    this.queueEnhancements();
  }
  
  buildWithLazyLoading() {
    // Phase L: Full DOM construction with intersection observer
    const observer = new IntersectionObserver((entries) => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          this.buildFullDOM();
          observer.unobserve(entry.target);
        }
      });
    }, { rootMargin: '200px' });
    
    observer.observe(this.element);
  }
  
  createBasicStructure() {
    // Simple DOM for LCP - no nested complexity
    return createTag('div', { class: 'basic-content' }, this.getBasicContent());
  }
  
  buildFullDOM() {
    // Phase L: Rich DOM structure
    const fullStructure = this.createEnhancedStructure();
    this.element.appendChild(fullStructure);
  }
}

Read the full file on GitHub · 449 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. 7d ago First seen · 449 lines · 2,921 tokens per session scan A d8aad088f48d

Subscribe to this mod's changes

dom-manipulation-best-practices is a cursor rule published in the GitHub repository adobecom/da-express-milo (6 stars, last pushed 2d ago), licensed Apache-2.0. It adds 2,921 tokens to every session, about $0.0146 per session on Opus 5. 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-31.