Heavy dependencies in Vanilla JS
Some libraries are heavy enough that pulling one in for a small feature dominates your bundle and brings its own performance footguns — 3D engines that leak GPU memory, animation libraries that read layout every frame, date libraries many times larger than the native alternative. AI agents reach for whatever library they’ve seen most, so a marketing page ends up shipping a full charting or animation runtime for one small effect.
Framework fixes
Symptoms
How VibeCheck catches it
In your widget · Problems
Framer Motion detected (58KB)
To your coding agent · MCP
agent › get_detected_issues
→ { detector: "heavy-library", issue: "Framer Motion detected (58KB)", threshold: "Matches one of 16 known heavy-library signatures (globals, DOM patterns, or script URLs)" }
The same string in your widget and in your agent’s context — no screenshot, no copy-paste.
Root causes
The fix for Vanilla JS
Dynamically import the library the first time the feature runs, and always dispose its resources (geometries, listeners, timelines) when you’re done to avoid leaks.
let mod
async function animate() {
mod ??= await import('gsap')
const tween = mod.gsap.to(el, { x: 100 })
return () => tween.kill() // dispose to avoid a leak
}Steps
- Identify the heavy library and how much of it you actually use
- Replace with a native/lighter option, or import a tree-shakeable subset
- If it must stay, lazy-load it and dispose its resources on teardown
FAQ
- Which libraries does VibeCheck flag?
- It fingerprints 16 known-heavy libraries — 3D engines, animation runtimes, charting, CSS-in-JS, date and utility libraries — by their globals, DOM markers, or script URLs, and reports the weight plus that library’s common pitfalls.
- Do I have to remove the library?
- Not necessarily. Often lazy-loading it (so only users who need the feature download it) or importing a lighter subset is enough. Removal only makes sense when a native API or a much smaller package fully covers your use.
- What’s the single most common heavy dependency?
- Date libraries and animation runtimes. Moment.js is a classic — the native
Intl.DateTimeFormatreplaces most of it for zero bytes — and animation libraries are frequently shipped in full when a tree-shaken or lazy subset would do.