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
.claude/rules/js-batch-dom-css.mdWhat 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.stylewrites for one class - apply several CSS properties in a single
cssTextstring - drop a style-writing
useEffectfrom a React component - explain in review why a class beats inline styles
Example prompts for the agent
- Rewrite
updateElementStylesto add thehighlighted-boxclass instead of setting fourelement.styleproperties. - In the
Boxcomponent, stop writing styles inuseEffectand toggleclassNameinstead. - 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/js-batch-dom-css.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/js-batch-dom-css.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/js-batch-dom-css.mdManually: put the files in place
.clinerules/js-batch-dom-css.mdStep 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.