---
name: kill-framer-motion
description: Audit Framer Motion, Motion, and GSAP usage across your codebase, classify the ~90% of simple animations that do not need a JS animation runtime, replace them with mathematically matched CSS linear() springs, grid-template-rows folds, @starting-style, and WAAPI, and report the exact gzipped KB removed. Leaves genuinely complex shared-layout or gesture physics untouched.
license: MIT
metadata:
  author: Hairline UI
  url: https://hairlineui.com/skills/kill-framer-motion
  version: "1.0.0"
---

# /kill-framer-motion

Find the 90% of `framer-motion`, `motion/react`, `gsap`, and `aos` animations in your app that don't need a 35–50 KB JavaScript runtime, replace them with mathematically matched **CSS `linear()` springs**, `grid-template-rows: 0fr -> 1fr`, `@starting-style`, and the Web Animations API (`element.animate`), and report the exact bundle KB deleted.

This skill is **honest and surgical**: it never destroys complex animations that genuinely benefit from a JS orchestration engine (cross-route `layoutId` shared elements, multi-axis spring drag physics, complex timelines). It only replaces the trivial hovers, taps, fades, modals, accordions, and tab slides that bloat hydration for zero visual gain.

## Guardrails (never break these)

- **Preserve the exact spring feel.** Never replace a crisp spring (`stiffness: 300, damping: 24`) with a lazy `ease-in-out`. Use the bundled `--spring` solver to generate the exact matching CSS `linear()` curve and settle duration.
- **Leave truly complex animations alone.** If a component relies on cross-component `layoutId`, complex `useScroll` + `useTransform` multi-track scrubbing, or `dragConstraints` + `useDragControls`, keep it — and report clearly why it stayed.
- **Respect `prefers-reduced-motion: reduce`** on every CSS transition, keyframe, and WAAPI replacement (`motion-reduce:transition-none motion-reduce:animate-none`).
- **Only uninstall the package once 0 imports remain** across the entire codebase, and verify with typecheck + production build.

---

## Step 1 — Run the zero-dependency migration analyzer

Fetch and run the standalone analyzer directly against your repo root (pure Node.js, zero dependencies, runs in `< 200ms`):

```bash
curl -sL https://hairlineui.com/skills/kill-framer-motion-check.mjs -o /tmp/kill-framer-motion-check.mjs
node /tmp/kill-framer-motion-check.mjs .
```

*(On Windows PowerShell: `curl.exe -sL https://hairlineui.com/skills/kill-framer-motion-check.mjs -o $env:TEMP\kill-framer-motion-check.mjs` then `node $env:TEMP\kill-framer-motion-check.mjs .`.)*

The analyzer prints:
- Installed animation packages and estimated gzipped runtime size (`framer-motion`, `motion`, `gsap`, `aos`, `animejs`, `@react-spring/web`).
- Every importing file classified into **`REPLACEABLE`** vs **`KEEP`** with the exact APIs used (`whileHover`, `whileTap`, `initial/animate`, `whileInView`, `AnimatePresence`, vs `layoutId`, `drag`, `useTransform`).
- Whether the package can be fully uninstalled and total estimated gzipped KB saved.

### Generate exact CSS `linear()` springs from any Framer Motion config

Whenever you replace a `transition={{ type: "spring", stiffness, damping, mass }}`, run the built-in physics solver so the CSS curve matches the JS spring frame for frame:

```bash
node /tmp/kill-framer-motion-check.mjs --spring 320,24,1
```

It outputs the exact `linear(...)` timing function and settle duration in milliseconds, ready to drop into CSS or Tailwind v4 `@theme`.

---

## Step 2 — Replace each replaceable pattern with zero-dep equivalents

### 2.1 `whileHover` & `whileTap` (hover lift / tactile press)

```tsx
// Before (pulls 46 KB framer-motion runtime onto a button)
<motion.button whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.97 }} transition={{ type: "spring", stiffness: 400, damping: 25 }}>
  Save
</motion.button>

// After (0 KB JS — exact CSS linear() spring, Tailwind v4 transitions `scale` explicitly)
<button
  type="button"
  className="transition-[scale,background-color] duration-[380ms] ease-[var(--spring-snappy)] hover:scale-[1.02] active:scale-[0.97] motion-reduce:transition-none motion-reduce:hover:scale-100 motion-reduce:active:scale-100"
>
  Save
</button>
```

### 2.2 `initial={{ opacity: 0, y: 12 }} animate={{ opacity: 1, y: 0 }}` (mount entrance)

Use a tiny CSS `@keyframes` rule (or `@starting-style` for elements toggled from `display: none`):

```css
@keyframes fade-up {
  from { opacity: 0; translate: 0 12px; }
}
.enter-fade-up {
  animation: fade-up 480ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
@media (prefers-reduced-motion: reduce) {
  .enter-fade-up { animation: none; }
}
```
*(Use `backwards` fill mode, never `both`, so later inline/hover transitions are never overridden by the finished keyframe.)*

### 2.3 `AnimatePresence` + `height: "auto"` accordions & collapsibles

Never measure DOM height in JS for simple expand/collapse panels:

```tsx
<div
  className="grid transition-[grid-template-rows,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none"
  style={{ gridTemplateRows: open ? '1fr' : '0fr', opacity: open ? 1 : 0 }}
>
  <div className="min-h-0 overflow-clip" inert={!open}>
    {children}
  </div>
</div>
```

### 2.4 Sliding active tab indicators (`layoutId="active-tab"`)

Single-row tab/pill indicators do not need Framer Motion's layout projection engine. Measure `offsetLeft` / `offsetWidth` of the active button once in `useLayoutEffect` and glide a single `<span>` pinned to `left-0` with `transform: translateX(...)` and `width` — zero transition on first paint (`ready` flag), then `cubic-bezier(0.34, 1.36, 0.64, 1)` on `transform`.

### 2.5 `whileInView` scroll reveals

Replace `motion.div whileInView` with a 15-line shared `IntersectionObserver` hook (`threshold: 0.2`, `unobserve` after first reveal so it runs once) toggling `data-shown="true"`, paired with pure CSS transitions. Keep above-the-fold hero elements animating via CSS on load — never gate first paint behind `IntersectionObserver`.

### 2.6 Modal / popover enter & exit transitions

Use native `<dialog>` or mounted phase transitions (`closed | opening | open | closing`) with CSS `opacity` + `scale` (or `@starting-style` + `transition-behavior: allow-discrete` for modern browsers) — zero `AnimatePresence` wrapper needed.

### 2.7 Clean up unused packages

Once `node /tmp/kill-framer-motion-check.mjs .` reports `0` remaining imports for an animation library:
1. Remove it from `package.json` (`pnpm remove framer-motion` / `npm uninstall framer-motion`).
2. Define any reused CSS `linear()` springs once as custom properties in `globals.css` (`--spring-snappy`, `--spring-bouncy`) generated by `--spring`.

---

## Step 3 — Verify zero regressions and measure real KB saved

1. Re-run the analyzer:
   ```bash
   node /tmp/kill-framer-motion-check.mjs .
   ```
2. Run typecheck (`npm run typecheck` / `tsc --noEmit`) and production build (`npm run build`).
3. Inspect the replaced interactions in a browser (hover, tap, accordion, modal, tabs, and `prefers-reduced-motion: reduce`) to confirm identical visual feel.

---

## Step 4 — Report (keep it tight)

```text
/kill-framer-motion — migration complete

  Replaced animations:       21 / 21  (100% migrated)
  Kept in JS runtime:             0
  Packages removed:          framer-motion (-46.4 KB gzipped est.)
  CSS springs generated:          2  (--spring-snappy, --spring-bouncy)

Files changed:
- src/app/globals.css — added --spring-snappy and --spring-bouncy linear() tokens
- src/components/PricingTabs.tsx — replaced layoutId pill with offsetLeft transform glide
- src/components/FaqAccordion.tsx — replaced AnimatePresence height:auto with 0fr -> 1fr grid
- src/components/HeroCard.tsx — replaced motion.div whileHover/whileTap with CSS scale spring
- package.json — removed framer-motion

Not replaced (if any):
- none
```
