The use of animation is one of the best ways to make your website stand out. When smartly implemented, it can dazzle users and call attention to your most important content.
Of course, web animation has been around for years. But it’s really taken off with the spread of HTML5, CSS3 and JavaScript. Adding movement to your site has never been easier – or looked better.
Among the most powerful and fascinating tools for creating animation is the GreenSock Animation Platform (GSAP). It is known for its code-based approach and the ability to create some incredible special effects.
Today, we’ll cover the basics of GSAP. We’ll explain what it is and why you’d want to use it over other techniques. Plus, we’ll show you some examples of what it can do. Let’s get started!
Animation Through Code
At first, it may sound counterintuitive. Animation is a highly-visual art. So, why would we want to create this through code, rather than a traditional GUI-based tool? And what advantages does it have over good old CSS3 animation that has been built into the standard?
Here is why GSAP may be your best choice for creating animation:
It Works with the Elements Already on Your Page
Virtually any element on a page that can be accessed through JavaScript can be animated via GSAP. It doesn’t require you to create a separate canvas just for animation. CSS elements, SVG images and even JavaScript objects can be manipulated. This allows you to get up and running more quickly.
Compatibility Is Built In
GSAP has been tested across all the major web browsers – including legacy fare such as Internet Explorer. All of the browser-related tweaks and fallbacks have already been built into the platform. As such, you won’t have to create your own hacks to get things working across the board. This has all been done for you. If something’s not supported by a particular browser, it “silently” fails and won’t produce errors.
Meanwhile, GSAP also plays nicely with a variety of JavaScript frameworks and other technologies. So you can feel free to use it in conjunction with React, Vue or jQuery. Pretty much anything you’re already utilizing on your website is likely to be compatible.
It Uses Familiar, Easy to Learn Syntax
In addition to supporting CSS classes and IDs, GSAP also allows you to style animations using common properties. Formatting your code is a familiar mix of JavaScript and CSS. It even supports hex colors.
Fast Performance
Optimization is one of the key benefits of using GSAP. It offers a combination of HTML5 and JavaScript to allow for incredibly smooth animation. Support for hardware acceleration means that you’ll get great performance – even on slower devices. You can take a speed test to compare it other animation techniques such as jQuery and standard CSS.
Fine-Grain Control
When you start to explore GSAP, you may notice how detail-oriented it is. There is a large selection of built-in features that you can use to create virtually any type of animation. You can, for instance, choose to sequence multiple animations in a row or even randomize them. And that’s not even beginning to scratch the surface of what’s possible.
The documentation is deep and there are plenty of code examples you can use to get started. But to get a better understanding of what GSAP is capable of, this introductory video offers some terrific demonstrations:
[embedded content]
There Are Plenty of Extras
The GSAP core package (which is free) is required to get started – and it’s plenty powerful. But there are also a number of available plugins that can help you do more. There are plugins for tasks like morphing elements, implementing physics and visually drawing motion paths.
It’s worth noting, however, that plugins are only available to paying members of “Club GreenSock”. This provides special access to both the plugins and extended commercial licensing.
Plus, features are constantly being added to core. Version 3, for example, offers up a simplified API, staggered tween animations and default animation properties, to name a few.
GSAP in Action
Now that we know a little bit more about what makes GSAP such a compelling option, let’s check out some examples of what it can do.
The great thing about each of the following snippets is that they are hosted on CodePen. So, you can feel free to study them, fork them and get a deeper understanding of how everything works.
Deconstructed Advanced Staggers Grid
See the Pen GSAP 3 Deconstructed Advanced Staggers Grid by Pete Barr (@petebarr)
on CodePen.
Crinkled Variable Font
See the Pen GSAP 3 & ETC Crinkled Variable Font by Pete Barr (@petebarr)
on CodePen.
Simple Camera
See the Pen Simple Camera by Blake Bowen (@osublake)
on CodePen.
GSAP 3 Radio
See the Pen GSAP 3 Radio by Kasper De Bruyne (@kdbkapsere)
on CodePen.
MotionPath Distribute
See the Pen MotionPath Distribute GSAP 3.0 by Craig Roblewsky (@PointC)
on CodePen.
Heartbeat 3.0
See the Pen Heartbeat 3.0 by Chris Gannon (@chrisgannon)
on CodePen.
Squiggle Text Animation
See the Pen Squiggle text animation by Cassie Evans (@cassie-codes)
on CodePen.
Cube Walk
See the Pen GSAP 3 Cube Walk by Pete Barr (@petebarr)
on CodePen.
Circle Packed Particles
See the Pen Circle Packed Particles (GSAP3 + PixiJS v5) by Steve Gardner (@ste-vg)
on CodePen.
DConstruct
See the Pen DConstruct by Cassie Evans (@cassie-codes)
on CodePen.
Powerful Animation Made Easier
When it comes to methods for animating your web projects, GSAP offers a rare combination. It’s more powerful than web standards alone, yet it is also optimized for performance. With most other libraries, you tend to sacrifice the latter to get the former.
This lack of compromise, combined with the shiny examples above, make it easy to see why so many developers have adopted GSAP. GreenSock says over 10 million sites are running the software, and one imagines that number will only continue to grow.
So, if you’re looking to up your animation game, give GSAP a try. You’ll be able to work your way up from basic movements all the way to high-end effects quicker than you may have thought possible.
This post may contain affiliate links. See our disclosure about affiliate links here.