To run a specific script in Webflow using NPM, you’ll first need to understand that Webflow itself doesn't directly integrate with NPM. However, you can still use NPM to manage dependencies and build tools outside of Webflow (e.g., for minifying scripts or bundling assets), then embed the final JavaScript into your Webflow project.
Here’s a step-by-step guide to help you run and use an NPM-based script with your Webflow site.
cd your-folder-name
.npm init -y
to initialize the project and create a package.json
file.npm install
, e.g.,:npm install gsap
for animations,npm install axios
for HTTP requests.main.js
.import gsap from 'gsap';
gsap.to('.box', { x: 100 });
package.json
to include a script. Example:bundle.js
).<script src="..."></script>
tags.<script src="https://yourdomain.com/dist/bundle.js" defer></script>
To use an NPM script with Webflow, create your own local project, install dependencies, bundle your code, and then embed the final JavaScript file into your Webflow project using the Custom Code settings. Webflow itself doesn’t run npm scripts—you build externally and integrate the compiled output.