@istmx/skills 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +49 -0
  2. package/bin/cli.js +251 -0
  3. package/istm/SKILL.md +65 -0
  4. package/istm-animate/SKILL.md +87 -0
  5. package/istm-animate/animations/animation_utils.md +280 -0
  6. package/istm-animate/animations/animations.md +220 -0
  7. package/istm-animate/animations/core_motion.md +250 -0
  8. package/istm-animate/animations/examples/README.md +29 -0
  9. package/istm-animate/animations/examples/nuxt/app/app.vue +3 -0
  10. package/istm-animate/animations/examples/nuxt/app/composables/useGSAP.ts +91 -0
  11. package/istm-animate/animations/examples/nuxt/app/pages/index.vue +55 -0
  12. package/istm-animate/animations/examples/nuxt/nuxt.config.ts +4 -0
  13. package/istm-animate/animations/examples/nuxt/package.json +18 -0
  14. package/istm-animate/animations/examples/react/App.jsx +46 -0
  15. package/istm-animate/animations/examples/react/index.html +12 -0
  16. package/istm-animate/animations/examples/react/main.jsx +9 -0
  17. package/istm-animate/animations/examples/react/package.json +21 -0
  18. package/istm-animate/animations/examples/react/vite.config.js +7 -0
  19. package/istm-animate/animations/examples/vanilla/index.html +33 -0
  20. package/istm-animate/animations/examples/vanilla/main.js +36 -0
  21. package/istm-animate/animations/examples/vue/app.vue +47 -0
  22. package/istm-animate/animations/examples/vue/index.html +15 -0
  23. package/istm-animate/animations/examples/vue/main.js +9 -0
  24. package/istm-animate/animations/examples/vue/package.json +19 -0
  25. package/istm-animate/animations/examples/vue/vite.config.js +7 -0
  26. package/istm-animate/animations/framework_motion.md +262 -0
  27. package/istm-animate/animations/motion.csv +17 -0
  28. package/istm-animate/animations/motion.md +11 -0
  29. package/istm-animate/animations/motion_catalog.json +226 -0
  30. package/istm-animate/animations/motion_performance.md +75 -0
  31. package/istm-animate/animations/motion_plugins.md +429 -0
  32. package/istm-animate/animations/react_animations.md +132 -0
  33. package/istm-animate/animations/scroll_trigger_effects.md +291 -0
  34. package/istm-animate/animations/timeline_sequencing.md +103 -0
  35. package/istm-architecture/SKILL.md +109 -0
  36. package/istm-architecture/frameworks/angular.csv +51 -0
  37. package/istm-architecture/frameworks/astro.csv +54 -0
  38. package/istm-architecture/frameworks/avalonia.csv +57 -0
  39. package/istm-architecture/frameworks/flutter.csv +53 -0
  40. package/istm-architecture/frameworks/javafx.csv +76 -0
  41. package/istm-architecture/frameworks/jetpack-compose.csv +53 -0
  42. package/istm-architecture/frameworks/laravel.csv +51 -0
  43. package/istm-architecture/frameworks/nextjs.csv +53 -0
  44. package/istm-architecture/frameworks/nuxtjs.csv +59 -0
  45. package/istm-architecture/frameworks/react-native.csv +52 -0
  46. package/istm-architecture/frameworks/react.csv +54 -0
  47. package/istm-architecture/frameworks/svelte.csv +54 -0
  48. package/istm-architecture/frameworks/swiftui.csv +51 -0
  49. package/istm-architecture/frameworks/uwp.csv +56 -0
  50. package/istm-architecture/frameworks/vue.csv +50 -0
  51. package/istm-architecture/frameworks/winui.csv +60 -0
  52. package/istm-architecture/frameworks/wpf.csv +57 -0
  53. package/istm-architecture/templates/agents.md +229 -0
  54. package/istm-architecture/templates/architecture.md +111 -0
  55. package/istm-architecture/templates/design.md +138 -0
  56. package/istm-architecture/templates/project-overview.md +215 -0
  57. package/istm-awwward-designer/SKILL.md +43 -0
  58. package/istm-awwward-designer/libraries/threejs.csv +54 -0
  59. package/istm-awwward-designer/references/accessibility.md +774 -0
  60. package/istm-awwward-designer/references/anim-anti-patterns.md +576 -0
  61. package/istm-awwward-designer/references/animation-map.md +166 -0
  62. package/istm-awwward-designer/references/animation-standards.md +86 -0
  63. package/istm-awwward-designer/references/anti-patterns.md +191 -0
  64. package/istm-awwward-designer/references/color-systems.md +604 -0
  65. package/istm-awwward-designer/references/css-performance.md +477 -0
  66. package/istm-awwward-designer/references/descender-safety.md +490 -0
  67. package/istm-awwward-designer/references/design-audit.md +93 -0
  68. package/istm-awwward-designer/references/font-loading.md +378 -0
  69. package/istm-awwward-designer/references/image-optimization.md +440 -0
  70. package/istm-awwward-designer/references/invention-gate.md +356 -0
  71. package/istm-awwward-designer/references/micro-interactions.md +825 -0
  72. package/istm-awwward-designer/references/page-transitions.md +365 -0
  73. package/istm-awwward-designer/references/performance-standards.md +79 -0
  74. package/istm-awwward-designer/references/quality-gate.md +103 -0
  75. package/istm-awwward-designer/references/responsive-design.md +778 -0
  76. package/istm-awwward-designer/references/scoring-guide.md +201 -0
  77. package/istm-awwward-designer/references/scroll-patterns.md +668 -0
  78. package/istm-awwward-designer/references/stitch-brief.md +124 -0
  79. package/istm-awwward-designer/references/tech-stack.md +204 -0
  80. package/istm-awwward-designer/references/technical-audit.md +133 -0
  81. package/istm-awwward-designer/references/technique-families.md +293 -0
  82. package/istm-awwward-designer/references/testing.md +535 -0
  83. package/istm-awwward-designer/references/text-animation.md +585 -0
  84. package/istm-awwward-designer/references/typography.md +504 -0
  85. package/istm-awwward-designer/references/usability-audit.md +108 -0
  86. package/istm-awwward-designer/references/visual-standards.md +97 -0
  87. package/istm-design/SKILL.md +98 -0
  88. package/istm-design/colors/color_theory.md +293 -0
  89. package/istm-design/colors/colors.csv +193 -0
  90. package/istm-design/colors/colors_catalog.json +4034 -0
  91. package/istm-design/colors/palette.json +21 -0
  92. package/istm-design/styles/design_system.md +288 -0
  93. package/istm-design/styles/html-tailwind.csv +56 -0
  94. package/istm-design/styles/nuxt-ui.csv +71 -0
  95. package/istm-design/styles/product_design.md +55 -0
  96. package/istm-design/styles/shadcn.csv +61 -0
  97. package/istm-design/styles/style.md +12 -0
  98. package/istm-design/styles/styles.csv +85 -0
  99. package/istm-design/styles/styles_catalog.json +2018 -0
  100. package/istm-design/styles/ui-reasoning.csv +162 -0
  101. package/istm-design/styles/uno.csv +60 -0
  102. package/istm-design/typography/font_and_font.md +10 -0
  103. package/istm-design/typography/google-fonts.csv +1924 -0
  104. package/istm-design/typography/sans_serif_fonts.md +112 -0
  105. package/istm-design/typography/typography.csv +75 -0
  106. package/istm-design/typography/typography_catalog.json +964 -0
  107. package/istm-design/ux/app-interface.csv +31 -0
  108. package/istm-design/ux/charts.csv +26 -0
  109. package/istm-design/ux/icons.csv +106 -0
  110. package/istm-design/ux/landing.csv +35 -0
  111. package/istm-design/ux/products.csv +193 -0
  112. package/istm-design/ux/react-performance.csv +45 -0
  113. package/istm-design/ux/responsive_rules.md +62 -0
  114. package/istm-design/ux/storytelling.md +47 -0
  115. package/istm-design/ux/ux-guidelines.csv +100 -0
  116. package/istm-design/ux/ux_guidelines.json +1190 -0
  117. package/istm-system-design/SKILL.md +88 -0
  118. package/istm-system-design/principles/01-architecture-patterns.md +24 -0
  119. package/istm-system-design/principles/02-database-selection.md +32 -0
  120. package/istm-system-design/principles/03-api-design.md +25 -0
  121. package/istm-system-design/principles/04-authentication-security.md +23 -0
  122. package/istm-system-design/principles/05-caching-performance.md +21 -0
  123. package/istm-system-design/principles/06-asynchronous-processing.md +17 -0
  124. package/istm-system-design/principles/07-infrastructure-deployment.md +22 -0
  125. package/istm-system-design/principles/08-low-level-design.md +35 -0
  126. package/istm-system-design/principles/09-state-management.md +14 -0
  127. package/istm-system-design/principles/10-error-handling-and-logging.md +26 -0
  128. package/istm-system-design/principles/11-testing-strategy.md +18 -0
  129. package/istm-system-design/principles/12-seo-and-web-vitals.md +18 -0
  130. package/istm-system-design/stacks/SETUP.md +82 -0
  131. package/istm-system-design/stacks/STACK.md +67 -0
  132. package/istm-system-design/stacks/WORKFLOW.md +84 -0
  133. package/istm-system-design/templates/api-route.ts.template +32 -0
  134. package/istm-system-design/templates/migrations.md.template +30 -0
  135. package/istm-system-design/templates/schema.drizzle.ts.template +17 -0
  136. package/istm-system-design/templates/schema.prisma.template +28 -0
  137. package/istm-system-design/templates/trpc-router.ts.template +22 -0
  138. package/istm-system-design/templates/zod-validators.ts.template +14 -0
  139. package/istm-workflow/istm-audit/SKILL.md +108 -0
  140. package/istm-workflow/istm-audit/agent-prompt.md +393 -0
  141. package/istm-workflow/istm-audit/agents/openai.yaml +7 -0
  142. package/istm-workflow/istm-audit/modes/area.md +19 -0
  143. package/istm-workflow/istm-audit/modes/gapfill.md +12 -0
  144. package/istm-workflow/istm-audit/modes/greenfield.md +24 -0
  145. package/istm-workflow/istm-audit/modes/tool-skills.md +39 -0
  146. package/istm-workflow/istm-audit/modes/whole-repo.md +5 -0
  147. package/istm-workflow/istm-audit/patterns/clean-architecture.md +15 -0
  148. package/istm-workflow/istm-audit/patterns/domain-driven.md +16 -0
  149. package/istm-workflow/istm-audit/patterns/functional.md +16 -0
  150. package/istm-workflow/istm-audit/patterns/solid-oop.md +17 -0
  151. package/istm-workflow/istm-check/SKILL.md +52 -0
  152. package/istm-workflow/istm-check/agents/openai.yaml +7 -0
  153. package/istm-workflow/istm-check/modes/review.md +156 -0
  154. package/istm-workflow/istm-check/modes/verify.md +197 -0
  155. package/istm-workflow/istm-check/review-agent-prompt.md +57 -0
  156. package/istm-workflow/istm-check/review-guide.md +133 -0
  157. package/istm-workflow/istm-craft/SKILL.md +37 -0
  158. package/istm-workflow/istm-craft/agent-modes/architecture.md +73 -0
  159. package/istm-workflow/istm-craft/agent-modes/cross-cutting.md +65 -0
  160. package/istm-workflow/istm-craft/agent-modes/enhancement.md +45 -0
  161. package/istm-workflow/istm-craft/agent-modes/feature.md +85 -0
  162. package/istm-workflow/istm-craft/agent-prompt.md +249 -0
  163. package/istm-workflow/istm-craft/agents/openai.yaml +7 -0
  164. package/istm-workflow/istm-craft/internal/after-subagent.md +90 -0
  165. package/istm-workflow/istm-craft/internal/design-conversation.md +140 -0
  166. package/istm-workflow/istm-craft/internal/tool-discovery.md +58 -0
  167. package/istm-workflow/istm-craft/spec-template.md +278 -0
  168. package/istm-workflow/istm-debug/SKILL.md +102 -0
  169. package/istm-workflow/istm-debug/agents/openai.yaml +7 -0
  170. package/istm-workflow/istm-develop/SKILL.md +144 -0
  171. package/istm-workflow/istm-develop/agents/openai.yaml +7 -0
  172. package/istm-workflow/istm-develop/checklist.md +95 -0
  173. package/istm-workflow/istm-develop/flow/build.md +133 -0
  174. package/istm-workflow/istm-develop/flow/git.md +34 -0
  175. package/istm-workflow/istm-develop/logical-guide.md +99 -0
  176. package/istm-workflow/istm-develop/ui/existing.md +23 -0
  177. package/istm-workflow/istm-develop/ui/generate.md +131 -0
  178. package/istm-workflow/istm-develop/ui/image.md +41 -0
  179. package/istm-workflow/istm-develop/ui/implementation.md +281 -0
  180. package/istm-workflow/istm-develop/ui/mcp.md +11 -0
  181. package/istm-workflow/istm-develop/ui-guide.md +164 -0
  182. package/istm-workflow/istm-document/SKILL.md +123 -0
  183. package/istm-workflow/istm-document/agent-prompt.md +57 -0
  184. package/istm-workflow/istm-document/agents/openai.yaml +7 -0
  185. package/istm-workflow/istm-document/templates/changelog.md +54 -0
  186. package/istm-workflow/istm-document/templates/postmortem.md +58 -0
  187. package/istm-workflow/istm-document/templates/pr.md +43 -0
  188. package/istm-workflow/istm-document/templates/release-note.md +41 -0
  189. package/istm-workflow/istm-scope/SKILL.md +100 -0
  190. package/istm-workflow/istm-scope/agents/openai.yaml +7 -0
  191. package/istm-workflow/istm-scope/approaches/facade.md +33 -0
  192. package/istm-workflow/istm-scope/approaches/journey.md +31 -0
  193. package/istm-workflow/istm-scope/approaches/skateboard.md +33 -0
  194. package/istm-workflow/istm-scope/approaches/tracer-bullet.md +34 -0
  195. package/istm-workflow/istm-scope/modes/add.md +14 -0
  196. package/istm-workflow/istm-scope/modes/plan-brownfield.md +11 -0
  197. package/istm-workflow/istm-scope/modes/plan-greenfield.md +20 -0
  198. package/istm-workflow/istm-scope/modes/plan-monorepo.md +8 -0
  199. package/istm-workflow/istm-scope/modes/plan.md +120 -0
  200. package/istm-workflow/istm-scope/modes/replan.md +13 -0
  201. package/istm-workflow/istm-scope/scope-template.md +148 -0
  202. package/istm-workflow/istm-sync/SKILL.md +166 -0
  203. package/istm-workflow/istm-sync/agent-prompt.md +211 -0
  204. package/istm-workflow/istm-sync/agents/openai.yaml +7 -0
  205. package/istm-workflow/istm-test/SKILL.md +233 -0
  206. package/istm-workflow/istm-test/agent-prompt.md +62 -0
  207. package/istm-workflow/istm-test/agents/openai.yaml +7 -0
  208. package/istm-workflow/istm-test/modes/setup.md +97 -0
  209. package/istm-workflow/istm-test/writing-guide.md +196 -0
  210. package/package.json +35 -0
@@ -0,0 +1,477 @@
1
+ # CSS Performance — Deep Dive
2
+
3
+ CSS is render-blocking by default. The browser can't paint until it downloads and parses the CSSOM. Smart CSS delivery eliminates this bottleneck and keeps the main thread free for JavaScript.
4
+
5
+ ---
6
+
7
+ ## Critical CSS
8
+
9
+ Critical CSS is the minimum set of styles needed to render above-the-fold content. Inline it. Everything else gets deferred.
10
+
11
+ ### Extracting Critical CSS
12
+
13
+ ```bash
14
+ # Using penthouse
15
+ bunx penthouse --url https://yoursite.com --css styles.css --output critical.css
16
+
17
+ # Using critical (Node)
18
+ const critical = require('critical');
19
+ critical.generate({
20
+ inline: true,
21
+ base: 'dist/',
22
+ src: 'index.html',
23
+ target: 'index-critical.html',
24
+ width: 1300,
25
+ height: 900
26
+ });
27
+ ```
28
+
29
+ ### Manual Critical CSS Extraction
30
+
31
+ ```html
32
+ <head>
33
+ <!-- Inline critical CSS — renders immediately, no network request -->
34
+ <style>
35
+ /* Only what's needed for above-the-fold */
36
+ body { margin: 0; font-family: system-ui, sans-serif; }
37
+ .hero { min-height: 100vh; display: flex; align-items: center; }
38
+ .hero h1 { font-size: clamp(2rem, 5vw, 4rem); font-weight: 700; }
39
+ /* Nav, above-fold images, initial layout */
40
+ </style>
41
+
42
+ <!-- Non-critical CSS — loaded after page renders -->
43
+ <link
44
+ rel="preload"
45
+ href="styles.css"
46
+ as="style"
47
+ onload="this.onload=null;this.rel='stylesheet'"
48
+ >
49
+ <!-- Fallback for no-JS environments -->
50
+ <noscript><link rel="stylesheet" href="styles.css"></noscript>
51
+ </head>
52
+ ```
53
+
54
+ ### Critical CSS Patterns
55
+
56
+ ```css
57
+ /* Hero section — MUST be critical */
58
+ .hero {
59
+ display: grid;
60
+ place-items: center;
61
+ min-height: 100vh;
62
+ background: #0a0a0a;
63
+ color: #fff;
64
+ }
65
+
66
+ .hero h1 {
67
+ font-size: clamp(2.5rem, 8vw, 6rem);
68
+ font-weight: 800;
69
+ line-height: 1.1;
70
+ letter-spacing: -0.02em;
71
+ }
72
+
73
+ /* Hide below-fold elements in critical CSS to prevent FOUC */
74
+ [data-critical="hidden"] { visibility: hidden; }
75
+ [data-critical="hidden"].loaded { visibility: visible; }
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Defer Non-Critical CSS
81
+
82
+ ### The media="print" Trick
83
+
84
+ ```html
85
+ <!-- Step 1: Load as print stylesheet (non-blocking) -->
86
+ <link
87
+ rel="stylesheet"
88
+ href="styles.css"
89
+ media="print"
90
+ onload="this.media='all'"
91
+ >
92
+
93
+ <!-- Step 2: Fallback for no-JS -->
94
+ <noscript>
95
+ <link rel="stylesheet" href="styles.css">
96
+ </noscript>
97
+ ```
98
+
99
+ ### The preload Trick (Better)
100
+
101
+ ```html
102
+ <!-- Step 1: Preload but don't apply -->
103
+ <link
104
+ rel="preload"
105
+ href="styles.css"
106
+ as="style"
107
+ onload="this.rel='stylesheet'"
108
+ >
109
+
110
+ <!-- Step 2: Fallback -->
111
+ <noscript>
112
+ <link rel="stylesheet" href="styles.css">
113
+ </noscript>
114
+ ```
115
+
116
+ ### Modern Bundler Approach (Vite)
117
+
118
+ ```js
119
+ // vite.config.js
120
+ import { defineConfig } from 'vite';
121
+ import vitePlugin from 'vite-plugin-css-injected-by-js';
122
+
123
+ export default defineConfig({
124
+ plugins: [
125
+ // Injects CSS as JS strings — eliminates render-blocking link tags
126
+ cssInjectedByJs()
127
+ ]
128
+ });
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Avoiding @import
134
+
135
+ `@import` in CSS is render-blocking and causes a cascade:
136
+
137
+ ```css
138
+ /* BAD — creates serial loading chain */
139
+ @import url('fonts.css');
140
+ @import url('animations.css');
141
+ @import url('theme.css');
142
+ ```
143
+
144
+ ```
145
+ Browser: Parse base.css → Fetch fonts.css → Parse fonts.css →
146
+ Fetch animations.css → Parse animations.css → Render
147
+ ```
148
+
149
+ ```css
150
+ /* GOOD — separate link tags, parallel downloads */
151
+ ```
152
+
153
+ If you must use `@import`, put it inside a `<link rel="stylesheet">` — not at the top of a CSS file. The top-of-file `@import` is the worst pattern.
154
+
155
+ ---
156
+
157
+ ## CSS Containment
158
+
159
+ CSS containment isolates layout, style, and paint calculations to specific DOM subtrees. Prevents a change in one area from triggering recalculations everywhere.
160
+
161
+ ### contain: layout
162
+
163
+ ```css
164
+ /* Isolate this component's layout from the rest of the page */
165
+ .card {
166
+ contain: layout;
167
+ }
168
+ ```
169
+
170
+ **Use on:** Cards, list items, widget containers, anything that frequently updates or renders dynamically.
171
+
172
+ ### contain: paint
173
+
174
+ ```css
175
+ /* Prevent this element from being painted outside its bounds */
176
+ .modal-backdrop {
177
+ contain: paint;
178
+ }
179
+
180
+ /* Paint containment creates a stacking context */
181
+ .overlay {
182
+ contain: strict; /* layout + paint + style + size */
183
+ }
184
+ ```
185
+
186
+ ### Containment Values
187
+
188
+ | Value | What It Contains |
189
+ |-------|-----------------|
190
+ | `layout` | Layout isolation (defensive) |
191
+ | `paint` | Paint containment (no overflow) |
192
+ | `style` | Counter/list-style containment |
193
+ | `size` | Size containment (child can't affect parent) |
194
+ | `strict` | All of the above |
195
+ | `content` | Everything except size |
196
+
197
+ ### Containment + Dynamic Content
198
+
199
+ ```css
200
+ /* Container with fixed height for dynamic content */
201
+ .list-container {
202
+ contain: layout style;
203
+ content-visibility: auto; /* Skip rendering off-screen */
204
+ contain-intrinsic-size: 0 400px; /* Estimated height for scrollbar */
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## content-visibility
211
+
212
+ The `content-visibility` property lets the browser skip rendering work for off-screen content entirely.
213
+
214
+ ```css
215
+ /* Auto — browser skips rendering when off-screen */
216
+ .section-below-fold {
217
+ content-visibility: auto;
218
+ contain-intrinsic-size: 0 600px; /* Estimated height */
219
+ }
220
+
221
+ /* Visible — normal rendering (default) */
222
+ .above-fold {
223
+ content-visibility: visible;
224
+ }
225
+
226
+ /* Hidden — element skipped entirely (like display:none) */
227
+ .debug-panel {
228
+ content-visibility: hidden;
229
+ }
230
+ ```
231
+
232
+ **Impact:** Can reduce rendering time by 50%+ on long pages. Use `contain-intrinsic-size` to prevent scrollbar jumping (CLS).
233
+
234
+ ---
235
+
236
+ ## will-change — The Right Way
237
+
238
+ `will-change` tells the browser to promote an element to its own compositor layer. Used correctly, it enables GPU acceleration. Used incorrectly, it wastes GPU memory and hurts performance.
239
+
240
+ ### Correct Usage
241
+
242
+ ```css
243
+ /* Apply JUST before animation starts */
244
+ .animated-element {
245
+ will-change: transform, opacity;
246
+ }
247
+
248
+ /* Remove AFTER animation completes */
249
+ .animated-element.done {
250
+ will-change: auto;
251
+ }
252
+ ```
253
+
254
+ ### GSAP Integration
255
+
256
+ ```js
257
+ // GSAP can manage will-change automatically
258
+ gsap.to(element, {
259
+ x: 100,
260
+ opacity: 0,
261
+ willChange: 'transform, opacity', // GSAP handles it
262
+ onComplete: () => {
263
+ gsap.set(element, { clearProps: 'will-change' });
264
+ }
265
+ });
266
+ ```
267
+
268
+ ### Incorrect Usage (Don't Do This)
269
+
270
+ ```css
271
+ /* WRONG — Preemptively applying will-change everywhere */
272
+ * { will-change: transform; } /* Catastrophic — allocates GPU memory for everything */
273
+
274
+ /* WRONG — Using will-change without animation */
275
+ .will-animate-someday {
276
+ will-change: transform; /* Too early */
277
+ }
278
+
279
+ /* WRONG — will-change on too many properties */
280
+ .bad {
281
+ will-change: top, left, width, height, transform; /* Pick ONE */
282
+ }
283
+ ```
284
+
285
+ ### When will-change IS Appropriate
286
+
287
+ | Scenario | Correct `will-change` |
288
+ |----------|----------------------|
289
+ | Element about to animate with `transform` | `transform` |
290
+ | Element about to fade in/out | `opacity` |
291
+ | Scroll-linked animations | `transform` |
292
+ | Hover effects that use transform | `transform` |
293
+ | Page transition containers | `transform, opacity` |
294
+
295
+ ---
296
+
297
+ ## GPU-Accelerated Properties
298
+
299
+ ### The Safe List (Compositor-Only)
300
+
301
+ These properties run on the compositor thread — they never touch the main thread:
302
+
303
+ | Property | Use Case |
304
+ |----------|----------|
305
+ | `transform` | translate, scale, rotate, skew, matrix |
306
+ | `opacity` | Fade in/out, transitions |
307
+ | `filter` | blur, brightness, contrast, hue-rotate, drop-shadow |
308
+ | `clip-path` | Shape reveals, clip animations |
309
+ | `backdrop-filter` | Frosted glass, blurs behind elements |
310
+ | `scroll-snap` | Scroll snap points |
311
+ | `position: fixed` (static layout) | Fixed positioning (no layout dependency) |
312
+
313
+ ### The Forbidden List (Never Animate)
314
+
315
+ These properties trigger layout or paint — they are expensive:
316
+
317
+ ```
318
+ --- NEVER ANIMATE THESE ---
319
+ Layout properties: width, height, padding, margin, border
320
+ Position properties: top, left, right, bottom, inset
321
+ Font properties: font-size, font-weight, line-height, letter-spacing, font-family
322
+ Display properties: display, visibility
323
+ Overflow: overflow
324
+ Background: background-color, background-image (via URL)
325
+ Box model: border-radius, box-shadow, border-width
326
+ Color: color, border-color
327
+ Shadow: text-shadow
328
+ Content: content
329
+
330
+ --- USE TRANSFORM INSTEAD ---
331
+ ```
332
+
333
+ ### The Transform-First Rule
334
+
335
+ ```css
336
+ /* WRONG — triggers layout */
337
+ .bad { left: 100px; } /* Layout on every frame */
338
+
339
+ /* RIGHT — compositor-only */
340
+ .good { transform: translateX(100px); }
341
+
342
+ /* WRONG — animating width */
343
+ .bad { width: 100%; }
344
+
345
+ /* RIGHT — use scale from current width */
346
+ .good { transform: scaleX(1); }
347
+ ```
348
+
349
+ ### Composite Operations
350
+
351
+ ```css
352
+ /* layer-type: auto (default) — browser decides */
353
+ /* layer-type: gpu — force GPU compositing */
354
+ /* layer-type: cpu — software compositing (avoid) */
355
+
356
+ .accelerated {
357
+ transform: translateZ(0); /* Legacy force-GPU method */
358
+ /* Better: */
359
+ will-change: transform;
360
+ }
361
+ ```
362
+
363
+ ---
364
+
365
+ ## Tree-Shaking Unused CSS
366
+
367
+ Unused CSS dead weight ships to every user. Tree-shake it.
368
+
369
+ ### PurgeCSS (Recommended)
370
+
371
+ ```js
372
+ // vite.config.js
373
+ import { vite-plugin-purgecss } from 'vite-plugin-purgecss';
374
+
375
+ export default defineConfig({
376
+ plugins: [
377
+ purgeCss({
378
+ safelist: ['active', 'nav-open', 'gsap-*'], // Always keep these
379
+ blocklist: ['.debug-*', '.test-*'], // Always remove these
380
+ })
381
+ ]
382
+ });
383
+ ```
384
+
385
+ ### Manual Auditing
386
+
387
+ ```bash
388
+ # Use csscss to find duplicate rules
389
+ bunx csscss dist/styles.css
390
+
391
+ # Use uncss to remove unused selectors
392
+ bunx uncss --ignore ['.no-uncss'] http://localhost:3000
393
+ ```
394
+
395
+ ### CSS Modules / CSS-in-JS
396
+
397
+ ```js
398
+ // CSS Modules — only imported styles ship
399
+ import styles from './Card.module.css';
400
+ // Only .Card and its children styles are included
401
+ ```
402
+
403
+ ### Critical CSS Extraction + Defer
404
+
405
+ ```js
406
+ // Using vite-plugin-critical-css
407
+ import criticalPlugin from 'vite-plugin-critical-css';
408
+
409
+ export default defineConfig({
410
+ plugins: [
411
+ criticalPlugin({
412
+ critical: {
413
+ publicPath: 'dist/css/',
414
+ inline: true,
415
+ extract: true
416
+ },
417
+ nonCritical: {
418
+ inline: false,
419
+ media: 'print'
420
+ }
421
+ })
422
+ ]
423
+ });
424
+ ```
425
+
426
+ ---
427
+
428
+ ## CSS Performance Checklist
429
+
430
+ ```plaintext
431
+ □ Inline critical CSS in <head> (< 14KB compressed)
432
+ □ Defer non-critical CSS (media="print" + onload trick)
433
+ □ Never use @import in CSS files (creates serial chain)
434
+ □ contain: layout on frequently updating components
435
+ □ content-visibility: auto on below-fold sections
436
+ □ will-change applied just before animation, removed after
437
+ □ Only GPU-accelerated properties animated (transform, opacity, filter)
438
+ □ No layout property animations (width, height, top, left, etc.)
439
+ □ PurgeCSS / tree-shaking for unused selectors
440
+ □ CSS custom properties for consistency and reuse
441
+ □ contain: strict on modals and overlays
442
+ □ contain-intrinsic-size on content-visibility: auto elements (prevents CLS)
443
+ □ No @import at the top of CSS files
444
+ □ font-display: swap on all web fonts (also a CSS concern)
445
+ □ No unused CSS selectors shipping to production
446
+ ```
447
+
448
+ ---
449
+
450
+ ## CSS Performance Quick Reference
451
+
452
+ ```css
453
+ /* GPU acceleration shortcut */
454
+ .gpu { transform: translateZ(0); }
455
+
456
+ /* Contain everything (strict isolation) */
457
+ .isolated { contain: strict; }
458
+
459
+ /* Skip off-screen rendering */
460
+ .lazy-section { content-visibility: auto; contain-intrinsic-size: 0 500px; }
461
+
462
+ /* Animation preparation */
463
+ .ready { will-change: transform, opacity; }
464
+
465
+ /* Post-animation cleanup */
466
+ .done { will-change: auto; }
467
+
468
+ /* Image aspect ratio (CLS prevention) */
469
+ .media { aspect-ratio: 16 / 9; width: 100%; height: auto; }
470
+
471
+ /* No layout shifts on load */
472
+ .fallback-font {
473
+ size-adjust: 103%;
474
+ ascent-override: 95%;
475
+ descent-override: 25%;
476
+ }
477
+ ```