Open your agent-built landing page's package.json (the file at the top of a JavaScript project that lists the packages it depends on) and read the dependencies, the packages your project needs in order to run. If you see 'framer-motion' or 'motion' in there and you never asked for it, you're not alone. Agents, the AI coding tools that write code for you, add an animation library (a bundle of ready-made code for motion on a page) the way a contractor adds a fitting you didn't order: because it was in the truck.
The question you actually have is short. Do I need this? Can I delete it? Before anyone answers, find out what it's doing in your project. By the end you'll know how to find every place a library is used, and a one-question test for which animations the browser can now do on its own.
What you need
- A project that imports 'framer-motion' or 'motion'
- The terminal open in the project folder
- A browser to try the small examples in (I used Chromium 141.0.7390.37)
Step one: find out who's using it
One search tells you — 'grep' searches through your files for a pattern. Open the terminal (the text window where you type commands) in the project root, the folder that holds your package.json, and run:
grep -rnE "from ['\"](framer-motion|motion/react)['\"]" src
I made a small test project with three files that import it, and this is what came back:
src/components/Hero.jsx:1:import { motion } from "framer-motion"; src/components/Cards.jsx:1:import { motion, useScroll } from 'framer-motion' src/components/Tabs.jsx:1:import { AnimatePresence, motion } from "motion/react";
Each line shows a file, a line number, and an import, which is the line that pulls the library into that file. Notice the two names. The library is published under both, so search for both, or you'll think you're done when you're not. (That's how I understand the rename; check the package's own README for the current name before you rely on it.)
Why did the agent reach for it? Because a library was the usual way to get a fade in most of the examples it learned from. It isn't a judgment on your project. It's a default.
That's your whole inventory: three files. You're not deleting a "library" anymore. You're deciding about three specific components (separate pieces of your page's code), and each one is a smaller question.
The concept: the browser animates two pictures
Modern browsers can animate between two states of your page by themselves. This feature is called view transitions. You call one function, 'document.startViewTransition()', and hand it the code that changes the page. The browser does three things in order:
- Takes a screenshot of the page as it is now.
- Runs your code, which changes the page.
- Takes a screenshot of the new page, then fades from the first picture to the second.
Read that again, because everything else follows from it. The browser isn't animating your elements. It's animating two pictures of them.
Here's the smallest version I could build. Click a button, a card swaps from Plan A to Plan B. Save this as an .html file and open it in your browser:
<button id="go">Swap</button>
<div id="card">Plan A</div>
<script>
const card = document.getElementById('card');
function swap() {
const alt = card.classList.toggle('alt');
card.textContent = alt ? 'Plan B' : 'Plan A';
}
document.getElementById('go').addEventListener('click', () => {
if (!document.startViewTransition) return swap(); // no support: just swap
document.startViewTransition(swap); // the one line
});
</script>
The 'alt' class just changes the card's background colour. Here's the CSS (the language that styles the page) that goes with it, to put in a style tag in the same file — the whole thing is those two blocks, no keyframes (step-by-step animation instructions) and no animation code of mine:
#card { width: 200px; padding: 2rem; border-radius: 12px; background: #dbeafe; font-size: 1.5rem; } #card.alt { background: #fde68a; }
There's no 'view-transition-name' anywhere, so the browser crossfades the whole page — what it calls the root — which is why the output below is named 'root'. I rendered it in headless Chromium 141.0.7390.37 (a browser run without a window, driven by a script) and clicked the button. About a hundred milliseconds later I asked the page what was animating:
::view-transition-old(root) fade-out 250ms opacity 0.42449 ::view-transition-new(root) fade-in 250ms opacity 0.57551
Those two '::view-transition' entries are pseudo-elements — stand-in boxes the browser invents just for the transition, that you can style but never wrote. One fades out, one fades in, adding up to 1. Those are the two pictures, mid-crossfade, and the browser made them without being asked. Your digits will differ from mine, because they depend on the instant you sample inside the 250 millisecond window. The sum staying at 1 is the part that matters. When the transition finished, the animation list was empty and the card said Plan B. The page had really changed underneath all along.
Proof: a transition is a picture, not your element
Here's the moment I want you to remember. While those two pictures were fading, I asked the page what element sits where the card is.
// paste in the page's console, then it clicks Swap for you
const card = document.getElementById('card');
const b = card.getBoundingClientRect();
console.log('before:', document.elementFromPoint(b.x + 20, b.y + 20).tagName);
document.getElementById('go').click();
setTimeout(() => {
const r = card.getBoundingClientRect();
console.log('mid-flight:', document.elementFromPoint(r.x + 20, r.y + 20).tagName);
}, 100);
You can paste that into the Console (right-click the page, choose Inspect, then the Console tab). 'elementFromPoint' reports which element sits at a given spot on screen. It logged 'before: DIV' — your card — then, a tenth of a second into the transition, 'mid-flight: HTML'. The spot where the card sits is the page behind it, not the card. Let the transition finish and 'elementFromPoint' returns the card again.
For a quarter of a second, the thing you see isn't your card. It's an image laid over the page. You can't click it, hover it, or grab it, because there's nothing there to grab. A quarter of a second sounds harmless, but it tells you exactly what this tool can't do.
Show the code
<style>
button { min-height: 40px; padding: 0 16px; font: inherit; border: 1px solid #888; border-radius: 8px; background: #f2f2f2; cursor: pointer; }
#card { width: 200px; max-width: 100%; padding: 2rem; border-radius: 12px; background: #dbeafe; font-size: 1.5rem; margin: 12px 0; }
#card.alt { background: #fde68a; }
#log { font-family: monospace; font-size: 15px; background: #f6f6f6; padding: 8px; border-radius: 6px; white-space: pre-wrap; min-height: 5em; margin: 0; }
</style>
<p>Press Swap. The demo asks which element sits where the card is: before, a tenth of a second in, and after.</p>
<button id="go">Swap</button>
<div id="card">Plan A</div>
<p id="log" aria-live="polite">Press Swap to run the probe.</p>
<script>
const card = document.getElementById('card');
const log = document.getElementById('log');
function swap() {
const alt = card.classList.toggle('alt');
card.textContent = alt ? 'Plan B' : 'Plan A';
}
function whatIsThere() {
const r = card.getBoundingClientRect();
const el = document.elementFromPoint(r.x + 20, r.y + 20);
return el ? el.tagName : '(nothing)';
}
if (!document.startViewTransition) {
log.textContent = "Your browser doesn't support view transitions yet — the article explains the fallback. Swap still changes the card, just without the fade.";
}
document.getElementById('go').addEventListener('click', () => {
if (!document.startViewTransition) return swap(); // no support: just swap
const lines = ['before: ' + whatIsThere() + ' (your card)'];
log.textContent = lines.join('\n');
const t = document.startViewTransition(swap); // the one line
setTimeout(() => {
const tag = whatIsThere();
lines.push('mid-flight: ' + tag + (tag === 'DIV' ? '' : ' (the page behind: you see a picture)'));
log.textContent = lines.join('\n');
}, 100);
t.finished.then(() => setTimeout(() => {
lines.push('after: ' + whatIsThere() + ' (your card again, now ' + card.textContent + ')');
log.textContent = lines.join('\n');
}, 120));
});
</script>The deletion test: does the element need to be live?
So here's the test I'd run on each of those three files. For each animation, ask one question:
While the motion is happening, does anything need to be the real, live element?
If the answer is no, because the animation is just "was this, now that," the browser can have it. If yes, it stays.
Can go (a before-and-after swap):
- A section that fades in when the page loads or the tab changes.
- Switching between two views, two tabs, two cards, a light and dark theme.
- A list that re-sorts or an item that appears or disappears. This one is a grey area. The old picture can fade out, so plenty of exits work, but I only rendered the plain cross-fade above, so check yours.
Stays (needs the live element):
- Dragging. You can't grab a screenshot, and the probe above is why.
- Anything that follows the cursor or the scroll position while you move.
- Hover and press effects that respond the moment your pointer arrives.
- Motion you want to interrupt and reverse halfway.
I did not render a drag, so that list is the model's prediction, not a measurement. The one thing I measured is the mid-flight probe, and it's the reason I'd trust the prediction.
Now go back to your three files. 'Hero.jsx' fades a heading in on load: before and after. 'Tabs.jsx' (a .jsx file is a component written for React, a popular library for building pages) uses 'AnimatePresence', which exists to animate things as they leave, so it's the one to read carefully. 'Cards.jsx' imports 'useScroll', which means motion tied to your scroll position, live the whole time. Hero is a candidate, Tabs is a maybe, Cards stays. A maybe isn't a verdict, so resolve it the cheap way: ship the sure deletion, leave the library installed for the maybe, and come back to Tabs once you can watch its AnimatePresence exit with your own eyes. Write that next to each filename before you touch anything; it takes two minutes and stops you deleting a file you only half understood.
That's an answer you can defend: two of three files might go, and the library does not leave yet.
How to delete it without breaking the page
Don't uninstall first. Replace one component at a time, then re-run the search. This version counts the files that still use the library ('wc -l' counts lines):
grep -rlE "from ['\"](framer-motion|motion/react)['\"]" src | wc -l
On my test project that printed 3. Convert 'Hero.jsx' and it prints 2. Only when it prints 0 do you run 'npm uninstall framer-motion' (npm is the tool that installs and removes packages) and check that your project still builds. If it stops at 1, that one file is the whole reason you still ship the library. Now you can decide if one drag handler is worth the weight, instead of guessing.
Where it goes wrong
Two honest limits. I ran this in plain HTML, not inside React, where the update has to land inside the function you pass in, so test that in your own app before you trust my example. And browser support changes: before you rely on this in production, look up the current status in the Browser compatibility table on MDN's View Transition API page rather than trusting a number from me. I measured one engine.
Recap
- Search for every import of the library first; the answer is a short list of files, not a vague "library".
- 'document.startViewTransition()' animates two pictures of your page, not the elements themselves.
- A picture can't be dragged, hovered or followed, so anything that needs the live element most likely keeps its library.
- Replace one component at a time and re-run the search; uninstall only when it prints 0.
Next, run the grep on a project of your own and write a verdict next to each filename. You might remove nothing, and that's fine: the grep mattered more than the verdict.