{"success":true,"name":"audit-what-each-npm-import-ships-to-the-browser-before-adopt","description":"Frontend JS/TS project, about to install a package for a small need","category":"ai-brimind","path":"ai-brimind/audit-what-each-npm-import-ships-to-the-browser-before-adopt/SKILL.md","file":"SKILL.md","content":"---\nname: audit-what-each-npm-import-ships-to-the-browser-before-adopt\ndescription: \"Frontend JS/TS project, about to install a package for a small need\"\n---\n\n# Audit What Each npm Import Ships to the Browser Before Adopting It\n\n## When to use\nProject has a browser bundle (React, Next.js, or any bundled frontend), and you're about to add a dependency or import a big library for one function.\n\n## Example request\nFull date library imported to format one date → 70KB shipped for what a built-in browser API does; the platform already had the feature. — 'import { one } from big-lib' assumed to be small → the lib doesn't tree-shake and the whole thing ships; import cost is a property of the package, not your import line. — Chart library added for a single sparkline → bundle doubles and mobile load time jumps; a lighter purpose-built package or a few lines of SVG covers it. — Nobody ever looked at the bundle → three abandoned libs still ship on every page; a bundle analyzer makes the invisible weight visible.\n\n## Instructions\nAct as a shipping clerk who weighs every parcel before it goes on the truck, because users on slow phones pay for each kilobyte. Before adding or importing a frontend dependency: 1) Name the need precisely, then check the platform first — modern browser built-ins (Intl, fetch, URL, structuredClone, array methods) cover many things people still install packages for. 2) If a package is genuinely needed, check its cost before installing: its size, whether it tree-shakes, and whether a smaller focused alternative exists — a package's weight is data you can look up, not guess. 3) After adding, verify with the bundler's analyzer what actually got shipped — imports lie, the bundle doesn't. 4) Keep heavy things off the critical path: if it's only needed on one screen or after an interaction, load it lazily there instead of in the main bundle. 5) Periodically sweep: dependencies that no longer earn their weight get removed. If you can't tell whether the built-in covers your case, spike it for ten minutes before installing. Only adopt the dependency once its measured cost is confirmed acceptable for your slowest real user, and explain why the bytes it adds are justified against the built-in or lighter option.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #964\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}