JavaScript data structure and CSS rendering optimization — index maps, combined iterations, Set/Map lookups, immutable sort, loop min/max, property caching, SVG wrapper animation, layout thrashing, content-visibility. Use when optimizing hot loops, data processing, DOM performance, or scroll rendering.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
JavaScript data structure and CSS rendering optimization — index maps, combined iterations, Set/Map lookups, immutable sort, loop min/max, property caching, SVG wrapper animation, layout thrashing, content-visibility. Use when optimizing hot loops, data processing, DOM performance, or scroll rendering.
JS & CSS Optimization
Low-level JavaScript data structure patterns and CSS rendering optimizations.
JavaScript Data Optimization
1. Build Index Maps for Repeated Lookups
Multiple .find() calls by the same key should use a Map. Build map once (O(n)), then all lookups are O(1).
constadmins: User[] = [], testers: User[] = [], inactive: User[] = [];
for (const user of users) {
if (user.isAdmin) admins.push(user);
if (user.isTester) testers.push(user);
if (!user.isActive) inactive.push(user);
}
3. Use Set/Map for O(1) Lookups
Convert arrays to Set/Map for repeated membership checks.
let latest = projects[0];
for (let i = 1; i < projects.length; i++) {
if (projects[i].updatedAt > latest.updatedAt) latest = projects[i];
}
return latest;
Math.min(...arr) works for small arrays but fails for arrays > ~124K items (Chrome).
6. Early Length Check for Array Comparisons
Check array lengths before expensive comparison operations.