Course contentsShow
← Web Development
Lesson 2547 of 2,98246. Animation LibrariesFree lesson

Installing GSAP and Basic Setup

Learn how to install GSAP via CDN or npm and set up your first animation project.

Installing GSAP and Basic Setup

You'll learn how to add GSAP to your project and configure it for your first animation.

Now that you understand why GSAP is valuable, let's get it running in your project. GSAP can be integrated in two main ways, depending on your workflow.

Installation Methods

Via CDN (Quick Start)

The fastest way to get started is linking GSAP directly from a Content Delivery Network. Add this script tag to your HTML:

<script src="https://cdn.jsdelivr.net/npm/gsap@3.12/dist/gsap.min.js"></script>

This makes GSAP's methods globally available in your JavaScript immediately—perfect for quick prototypes or static sites.

Via npm (Production Projects)

For build-tool workflows (Webpack, Vite, etc.), install GSAP as a dependency:

npm install gsap

Then import it in your JavaScript files:

import { gsap } from "gsap";

This approach gives you better version control, tree-shaking benefits, and integrates cleanly with modern module systems.

Basic Project Setup

Once installed, GSAP is ready to use. The library exposes a global gsap object (CDN) or exports methods you can import (npm). You don't need complex configuration files or initialization steps—just reference it and start animating.

Think of GSAP like a utility belt: once you've strapped it on (installed it), all the tools are immediately accessible without assembly required.

Which Method to Choose?

Use the CDN for learning, CodePen demos, or simple pages. Choose npm for team projects, version-locked dependencies, and build pipelines where you want reproducible installs.

Key Takeaway: GSAP installs via CDN (script tag) for quick starts or npm for production workflows—no additional configuration needed before animating.