Skip to main content
rule CX Codex

js-batch-dom-css · jarrodwatts — Claude Code rule: batch DOM style changes

js-batch-dom-css — a Claude rule that keeps the agent from writing styles one property at a time and pushes it toward a class or a single cssText string.

no license ★ 1,064 updated 2026-01-21

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/js-batch-dom-css.md
Open on GitHub

What js-batch-dom-css does

The rule lives in your project and shapes how the agent rewrites code that touches element styles. Four separate writes to element.style become one class, or one style.cssText assignment. Every lone write makes the browser redo layout; batching keeps it to a single pass.

Four cases are laid out: the slow version, the class version, the cssText version, and a React component where a useEffect that sets styles one by one is swapped for a className toggle. Classes get the nod over inline styles, since the browser caches them and the markup stays readable.

Impact is marked MEDIUM in the rule header, so treat this as cleanup rather than an emergency. It is about the browser DOM and layout recalculation. Bundle size is a different problem.

What it helps with

  • rewrite a style update so layout is recalculated once
  • swap a chain of element.style writes for one class
  • apply several CSS properties in a single cssText string
  • drop a style-writing useEffect from a React component
  • explain in review why a class beats inline styles

Example prompts for the agent

  • Rewrite updateElementStyles to add the highlighted-box class instead of setting four element.style properties.
  • In the Box component, stop writing styles in useEffect and toggle className instead.
  • Check this file against the js-batch-dom-css rule and list where styles change one property at a time.

How to install js-batch-dom-css

Manually: put the files in place

.claude/rules/js-batch-dom-css.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about js-batch-dom-css

How do I install js-batch-dom-css in Claude Code?

Copy the rule file from jarrodwatts/claude-code-config into your project at .claude/rules/js-batch-dom-css.md.

What does js-batch-dom-css do?

It has the agent group CSS changes into one class or one cssText assignment instead of writing properties one by one, which cuts layout recalculations.

Should I use a class or cssText?

A class sits in your stylesheet and gets cached by the browser, while cssText sets the properties inline in one go. The rule leans toward classes where you can.

Similar IDE rules

All IDE rules for Frontend and UI →

js-batch-dom-css by other authors comes first.

js-batch-dom-css tech-leads-club js-batch-dom-css prevents layout thrashing by separating style updates from layout queries. Helps Claude write performant DOM and React code. CX Codex +1 ★ 7,191repo stars inspecting-hermes-desktop-dom Hermes Agent The inspecting-hermes-desktop-dom skill reads the live DOM, computed CSS, and console output from Hermes Desktop over CDP. Use it to check whether a UI change took effect or identify the style rule in control. CX Codex +1 263installs expo-dom expo expo-dom runs web code in a webview on native platforms and renders as-is on web. Lets you use web libraries like recharts or react-syntax-highlighter in Expo without rewriting. CX Codex +1 25,700installs measuring-dom-nodes coleam00 The measuring-dom-nodes rule covers measuring DOM element sizes inside Remotion compositions without the video container's scale distorting the numbers. CX Codex +1 ★ 849repo stars js-performance-patterns patterns.dev js-performance-patterns is a Claude Code skill with runtime patterns for JavaScript hot paths, including tight loops, frequent event callbacks, and DOM operations. CX Codex +1 716installs pixijs-scene-dom-container pixijs pixijs-scene-dom-container teaches the agent how to overlay HTML elements on a PixiJS v8 canvas with DOMContainer and DOMPipe. Useful for native inputs, iframes or video that must follow a display object. CX Codex +1 6,900installs view-transitions patterns.dev Teaches your agent the View Transitions API, so page and UI state changes animate without hand-written animation code. CX Codex +1 707installs

From the same set20

The whole set →
rendering-content-visibility The rendering-content-visibility rule applies content-visibility: auto to long lists so off-screen items can wait before rendering. It fits message feeds and other scrollable collections. CX Codex +1 ★ 1,064repo stars rerender-dependencies rerender-dependencies — a Claude rule that keeps useEffect dependency arrays on primitives like user.id rather than whole objects, so an effect stops firing on every field change. CX Codex +1 ★ 1,064repo stars testing The testing rule sets conventions for TypeScript test files and the __tests__ directory. Use it to guide checks for success cases, failures, and edge conditions. CX Codex +1 ★ 1,064repo stars forge The forge rule configures Foundry workflows for Abstract and tells Claude Code to use the ZKsync mode for Solidity projects. CX Codex +1 ★ 1,064repo stars codebase-search codebase-search finds where a feature lives in your repo and hands back absolute paths plus a short explanation of the flow. CX Codex ★ 1,064repo stars media-interpreter media-interpreter — a subagent for working with PDFs, images, diagrams, and other binary formats. Extracts text, tabular data, and descriptions of visual content when standard file reading isn't an option. CX Codex ★ 1,064repo stars tech-docs-writer tech-docs-writer explores unfamiliar codebases to generate and maintain technical documentation, README files, and API guides with verified code samples. CX Codex ★ 1,064repo stars open-source-librarian The open-source-librarian subagent investigates open-source libraries and codebases, tracing implementations and linking to exact GitHub lines. Use it for source-level and change-history questions. CX Codex ★ 1,064repo stars

Project sponsors

Companies that keep this analytics open