3. Setting Up GSAP in WordPress and BricksBuilder
This module moves from theory into implementation. Its role is to show you how GSAP fits into a real WordPress and BricksBuilder environment, how to load it correctly, and how to avoid common setup mistakes that often confuse beginners. Instead of treating installation as a minor technical step, the course presents it as the foundation for everything that follows. If your environment is not clean and predictable, animation work becomes frustrating very quickly. 🛠️
You will learn the practical options for adding GSAP to a WordPress site, including script loading strategies, where custom code can live, and how BricksBuilder’s structure influences your workflow. The module also introduces the relationship between HTML structure, CSS classes, selectors, and JavaScript targeting—an essential bridge for learners who are not yet fully comfortable with front-end development. This helps you understand not just how to make GSAP available, but also how to connect it meaningfully to the elements you want to animate.
In addition, this section establishes good habits early: organizing code clearly, testing animations safely, checking whether scripts fire at the right time, and keeping your setup maintainable as projects grow. It also prepares the ground for later Glaze usage by making sure you first understand the underlying GSAP environment. By the end of the module, you should have a working animation-ready setup in WordPress and BricksBuilder and feel confident enough to begin writing your first real GSAP animations. ✅
3.1 What GSAP is and why developers love it
When talking about animation on the modern web, GSAP is one of the first tools that experienced front-end developers mention—and for good reason. In the context of WordPress and BricksBuilder, GSAP can be the difference between a site that merely looks assembled and one that feels intentional, polished, and alive ✨
At its core, GSAP gives developers precise control over how elements move, fade, scale, rotate, stagger, respond to scrolling, and transition between states. But that simple description still undersells it. To understand why developers love GSAP so much, it helps to look at both what it is technically and what problems it solves in real-world site building.
what GSAP is
GSAP stands for GreenSock Animation Platform. It is a high-performance JavaScript animation library used to animate:
- HTML elements
- CSS properties
- SVGs
- Canvas elements
- JavaScript object values
- Scroll-driven interactions
- Complex animation sequences and timelines
In practical terms, GSAP lets you tell the browser things like:
- move this element from left to right,
- fade this heading in,
- animate cards one after another with a stagger,
- pin a section during scroll,
- synchronize multiple animations in a timeline,
- or trigger effects only when an element enters the viewport 👀
Unlike many simpler animation solutions, GSAP is not just a collection of predefined effects. It is a robust animation engine. That distinction matters.
A typical “lightweight animation library” might offer a few built-in entrance effects such as fade-up, fade-left, zoom-in, and so on. GSAP, by contrast, gives you a system for building animation logic. You are not limited to presets—you can design motion exactly as needed.
the basic idea behind GSAP
GSAP works by animating values over time.
If an element starts with:
opacity: 0y: 50
and ends with:
opacity: 1y: 0
GSAP calculates the intermediate values smoothly over a specified duration. That may sound simple, but the power comes from how much control you get over:
- Timing
- Easing
- Sequencing
- Trigger conditions
- Responsiveness
- Performance optimization
For example, a developer can define:
- a start state,
- an end state,
- a duration,
- an easing curve,
- and whether the animation should run immediately, on click, or during scroll.
That means GSAP is equally useful for:
- subtle UI polish,
- dramatic hero-section entrances,
- storytelling sections,
- product reveals,
- interactive landing pages,
- and highly choreographed scroll experiences.
why GSAP matters more than “just animation”
On the surface, animation may seem decorative. But in professional web design and development, motion often serves important functional roles 🎯
motion can improve communication
Animation can help users understand:
-
Hierarchy
Important content can enter first or more prominently. -
Relationship
Elements moving together suggest that they belong together. -
State changes
A menu opening, a filter updating, or a modal appearing becomes easier to interpret. -
Direction and flow
Motion can guide attention down a page or toward a call to action. -
Feedback
Hover animations, loading indicators, and transition states reassure users that the interface is responding.
GSAP is especially valued because it allows these effects to be implemented with precision rather than randomness. Developers can craft motion that feels smooth, deliberate, and aligned with the brand.
why developers love GSAP
There are many animation tools available, including CSS transitions, CSS keyframes, the Web Animations API, and smaller JavaScript libraries. So why does GSAP have such a strong reputation among professionals? The answer is that it solves a number of problems exceptionally well.
1. it is extremely powerful
GSAP can handle animations ranging from very simple to highly complex.
A beginner might use it to animate a button fade-in. An advanced developer might use it to create:
- a timeline with overlapping sequences,
- scroll-synced panel transitions,
- text reveal effects,
- SVG morphing,
- pinned storytelling sections,
- or interactive page choreography.
The same library scales from small enhancements to large production builds. That flexibility is a huge reason developers adopt it early and keep using it.
2. it performs very well
Performance is one of GSAP’s biggest strengths ⚡
Animations can easily become janky if they are not handled carefully. Poor animation harms user experience more than no animation at all. GSAP is built with performance in mind and is known for:
- Efficient rendering
- Smooth frame updates
- Cross-browser consistency
- Optimization around animated values
- Reliable handling of transforms and opacity
In web animation, performance is often tied to animating properties the browser can render efficiently, especially transforms like:
xyscalerotationopacity
GSAP makes this kind of animation straightforward and ergonomic. Developers appreciate that they can achieve polished results without constantly fighting the browser.
3. it has a great API
One reason GSAP feels so loved in the developer community is that its API is clear, expressive, and enjoyable to work with 😊
For example, the core methods are intuitive:
gsap.to()gsap.from()gsap.fromTo()gsap.timeline()
Even without seeing much code, many developers immediately understand the intent:
to()animates to a target statefrom()animates from a starting statefromTo()explicitly defines both start and end statestimeline()sequences multiple animations together
That readability matters a lot in real projects. Code is not only written—it is maintained, reviewed, and revisited months later. GSAP tends to produce animation code that is relatively easy to reason about.
4. timelines are a major advantage
One of GSAP’s most beloved features is the timeline system.
Without a timeline, complex animations often become messy. Developers end up chaining delays manually, coordinating independent animations awkwardly, and recalculating timing if anything changes.
A GSAP timeline solves that elegantly.
With a timeline, a developer can:
- add animations in sequence,
- overlap them,
- control the whole animation as one unit,
- pause or reverse it,
- restart it,
- or synchronize it with user interaction.
This is especially useful in page-builder workflows like BricksBuilder, where sections often contain multiple elements:
- heading,
- subheading,
- buttons,
- image,
- decorative background elements.
Instead of animating each item with disconnected logic, GSAP allows all of them to be orchestrated in a coherent sequence. That creates a much more professional result.
5. easing control is excellent
Animation quality is not just about what moves, but how it moves.
The term easing describes the rate of change over time—whether an animation starts slowly, accelerates, decelerates, overshoots, or bounces. In conceptual terms, if progress is represented by a value $p$ over time $t$, easing changes the relationship so that motion does not feel linear or robotic.
Instead of a simplistic linear relationship like $p = t$, easing functions shape the curve so movement feels more natural.
Developers love GSAP because its easing options are:
- easy to apply,
- expressive,
- professional-looking,
- and suitable for both subtle and dramatic motion.
Good easing is one of those details users may not consciously notice, but they absolutely feel it. A site with well-tuned easing often feels more premium.
6. scroll-based animation is exceptionally strong
For WordPress and BricksBuilder users, this point is especially important 📌
Modern websites often rely on scroll interactions such as:
- reveal-on-scroll,
- parallax effects,
- pinned sections,
- progress-based animations,
- section transitions,
- and storytelling sequences tied to page movement.
GSAP’s ecosystem—especially with ScrollTrigger—is one of the most respected solutions for this kind of work.
Developers love it because scroll animation is notoriously tricky. Challenges include:
- viewport calculations,
- trigger timing,
- responsiveness,
- refresh behavior on resize,
- smooth synchronization,
- and avoiding layout glitches.
GSAP handles these challenges with a level of maturity that saves developers a great deal of time and frustration.
7. it works well with real layouts
This is one of the biggest practical reasons GSAP is so useful in WordPress environments.
Real websites are not clean demo files. They contain:
- nested containers,
- responsive breakpoints,
- dynamically generated content,
- theme styles,
- builder-generated markup,
- sticky headers,
- lazy-loaded media,
- and sometimes plugin conflicts.
Developers love GSAP because it is flexible enough to work inside these realities rather than only in idealized examples.
With BricksBuilder specifically, GSAP can be applied to:
- elements with custom classes,
- builder-generated sections and containers,
- reusable components,
- dynamic content loops,
- popups and off-canvas panels,
- and custom code areas.
That makes it a strong fit for production WordPress sites, not just experimental microsites.
8. it reduces the pain of cross-browser inconsistencies
Historically, browser differences have made animation frustrating. Even when standards improve, there are still implementation details, rendering quirks, and timing inconsistencies that developers need to account for.
GSAP has long been respected for smoothing over many of those rough edges. That does not mean it magically removes every browser issue, but it does mean developers spend less time debugging strange animation behavior.
That reliability builds trust. And developers tend to love tools they can trust.
9. it is suitable for both micro-interactions and large experiences
A great animation library should not force a project into one style of motion.
GSAP can be used for tiny enhancements such as:
It can also drive full-scale experiences such as:
- immersive landing pages,
- multi-step scroll narratives,
- animated product showcases,
- complex homepage hero sections,
- interactive brand storytelling.
That range is important. Developers do not want one tool for “small motion” and another for “serious animation” if they can avoid it. GSAP often becomes the single trusted animation layer across a project.
10. it is highly controllable
GSAP is not only about starting animations—it is about controlling them.
Developers can often:
- pause animations,
- resume them,
- reverse them,
- restart them,
- scrub them with scroll,
- kill them when no longer needed,
- or trigger them based on custom logic.
This level of control is very valuable in advanced interfaces. For instance, if a menu opens and closes repeatedly, or a modal needs entrance and exit transitions, or a scroll section must update based on viewport changes, control becomes essential.
GSAP gives developers that control without requiring them to reinvent animation state management from scratch.
11. it is well documented and widely respected
Another reason developers love GSAP is the surrounding ecosystem 📚
A tool becomes far more useful when it has:
- solid documentation,
- real-world examples,
- an active community,
- tutorials,
- and long-term industry credibility.
GSAP has all of these. That matters especially in WordPress development, where teams often need solutions that are maintainable and understandable by others. A library that only one niche expert understands is risky. GSAP is much easier to justify in professional workflows because it is so well established.
how GSAP compares to CSS animation alone
It is important to say clearly: CSS animations and transitions are not bad. In fact, they are often the right choice for simple hover effects or lightweight UI transitions.
However, developers often switch to GSAP when they need more than CSS can comfortably provide.
CSS is often enough for
- simple hover transitions,
- straightforward opacity or transform changes,
- basic keyframe loops,
- small decorative effects.
GSAP becomes preferable when you need
- precise sequencing
- complex timelines
- runtime control
- scroll synchronization
- advanced stagger logic
- conditional triggering
- better orchestration across multiple elements
- more maintainable animation code for large interfaces
In other words:
- CSS is excellent for simple, isolated motion.
- GSAP shines when animation becomes part of the application logic or page experience.
That is one of the biggest reasons developers love it: it gives them a toolset that matches the complexity of modern websites.
why GSAP is especially relevant in WordPress and BricksBuilder
In WordPress, many users start with page-builder animations because they are easy to apply visually. That convenience is useful, but built-in animations can become limiting when a project needs more polish or custom behavior.
GSAP becomes attractive because it adds a developer-grade animation layer on top of a builder workflow.
For a BricksBuilder project, that means you can move beyond default effects and create:
- entrance animations tailored to the layout,
- staggered card reveals,
- hero animations tied to load or scroll,
- pinned sections for storytelling,
- synchronized motion between text and imagery,
- custom interactions for menus, popups, and components.
Developers love this because it preserves the speed of a visual builder while restoring the fine-grained control of custom front-end development.
In other words, GSAP helps bridge two worlds:
- the efficiency of WordPress and BricksBuilder
- the precision of handcrafted interactive development
That combination is powerful 💡
a deeper reason developers love GSAP: it makes motion feel intentional
There is also a less technical reason behind GSAP’s popularity.
Developers and designers often care deeply about the feel of an interface. They do not just want elements to move—they want them to move in a way that matches:
- the brand,
- the content,
- the pacing,
- the emotional tone,
- and the user journey.
GSAP supports that kind of intentionality.
A luxury brand site might need slow, elegant, restrained transitions.
A startup landing page might need energetic, crisp motion.
A portfolio site might need cinematic scroll choreography.
A SaaS dashboard might need subtle, efficient micro-interactions.
GSAP is loved because it can support all of these styles without boxing developers into generic presets.
common developer sentiments about GSAP
If you spend time in front-end communities, the praise for GSAP tends to cluster around a few recurring themes:
-
“It just works.”
Developers value reliability enormously. -
“It makes hard things easier.”
Especially timelines and scroll interactions. -
“The API feels good.”
Good developer experience matters more than people sometimes admit. -
“It is production-ready.”
Not just fun for demos, but dependable for real client work. -
“It gives me control.”
This may be the single most important point.
That last point is worth emphasizing: GSAP gives control without excessive pain. That is a rare combination.
what this means for your WordPress/BricksBuilder workflow
When introducing GSAP into a WordPress and BricksBuilder project, you are not merely adding “fancier animation.” You are adding a system that can improve how you build and structure motion across the site.
That means:
-
More consistency
Animations can follow shared timing and easing rules. -
More scalability
You can build small effects now and more advanced interactions later. -
More maintainability
Instead of scattered ad hoc animation settings, you can centralize logic. -
More polish
Motion can be tuned to feel smoother and more intentional. -
More creative freedom
You are no longer restricted to whatever default animation controls the builder exposes.
For developers, this is exciting because it expands what WordPress can do without abandoning the WordPress ecosystem.
in summary
GSAP is a professional-grade JavaScript animation platform that allows developers to create smooth, high-performance, highly controllable animations for the web.
Developers love it because it offers:
- power
- performance
- precise control
- excellent timelines
- strong easing options
- industry-leading scroll animation capabilities
- good maintainability
- reliability in real-world builds
- flexibility across simple and advanced use cases
In the specific context of WordPress and BricksBuilder, GSAP is especially valuable because it adds custom animation capability on top of visual site-building workflows. It enables developers to create experiences that feel more refined, more branded, and more interactive—without being boxed in by default builder animations.
So if you are setting up GSAP in a BricksBuilder-based WordPress site, the key idea is this:
GSAP is not just an animation library. It is a motion framework for front-end craftsmanship 🛠️
And that is exactly why so many developers genuinely love working with it.
suggested transition to the next subsection
A natural next step after this explanation would be:
- how GSAP fits into a WordPress architecture
- where to enqueue or load GSAP
- how to target BricksBuilder elements safely
- and how to structure animations so they remain maintainable
If you want, I can also expand the next part in the same style—such as “3.2 How GSAP integrates into WordPress and BricksBuilder technically”.
3.3 Different ways to add GSAP to a WordPress site
If you want to use GSAP in WordPress—especially together with BricksBuilder—there are several valid ways to include it. Which one is “best” depends on how comfortable you are with code, how reusable your setup should be, and how much control you want. 🎯
This topic is important because many animation problems are not caused by GSAP itself, but by how it was loaded, when it becomes available, or where your custom code runs.
In practice, there are four main approaches you should know:
- adding GSAP via a CDN directly in the page or template
- adding GSAP globally via WordPress enqueueing
- adding GSAP through a code snippets/plugin-based workflow
- bundling GSAP in a custom theme or child theme workflow
For a WordPress + BricksBuilder user, you do not need to master all of them immediately. But you should understand the pros and cons of each, because later—when your projects grow—you may want to switch from a quick setup to a cleaner, more scalable one.
before we compare the methods: what does “adding GSAP” actually mean?
When you “add GSAP” to a website, you usually need to load:
- the core GSAP library
- optionally one or more plugins, such as:
ScrollTriggerScrollToPluginTextPlugin- others depending on your needs
- your own custom animation code, which uses GSAP
A simple mental model is:
- first the browser loads GSAP
- then it loads any GSAP plugins
- then it loads your own script that says what should animate
If this order is wrong, your code may fail.
For example, this will only work if GSAP has already been loaded:
gsap.to(".box", {
x: 200,
duration: 1
});
And this will only work if both GSAP and ScrollTrigger are already loaded and registered:
gsap.registerPlugin(ScrollTrigger);
gsap.to(".box", {
scrollTrigger: ".box",
y: 100,
duration: 1
});
So whenever we discuss “ways to add GSAP,” we are really discussing:
- where the files come from
- where they are inserted into WordPress
- in what order they are loaded
- whether they are loaded on one page or the whole site
- how easy it is to maintain later
method 1: adding GSAP via CDN directly in a page, template, or code block
This is usually the fastest way to get started. 🚀
A CDN is a hosted URL from which the browser loads a JavaScript file. Instead of storing GSAP inside your theme, you link to it from an external source.
how this works
You place a <script> tag somewhere in your site output, for example:
- in a custom code area in Bricks
- in the page/template footer
- in a header/footer injection plugin
- in a custom HTML/code element
Example:
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
<script>
gsap.to(".box", {
x: 200,
duration: 1
});
</script>
If you need ScrollTrigger, you also load that:
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js"></script>
<script>
gsap.registerPlugin(ScrollTrigger);
gsap.to(".box", {
scrollTrigger: ".box",
y: 100,
duration: 1
});
</script>
where you might do this in WordPress / Bricks
Possible places include:
- Bricks page settings or template-level custom code
- a Code element in Bricks
- a plugin that allows header/footer scripts
- theme options or site settings that allow custom scripts
why beginners often like this method
Because it is:
- quick
- visual
- easy to test
- ideal for learning
You can create a section in Bricks, give it a class like .box, paste in a script, and immediately see something move.
advantages
-
very easy to start
- no theme file editing required
- no enqueue function needed
- minimal WordPress knowledge needed
-
good for experiments
- useful when learning GSAP basics
- useful when building a one-off prototype
- useful when testing a small effect on a single page
-
page-specific loading
- you can load GSAP only where needed
- this can be helpful if only one landing page uses animation
disadvantages
-
harder to maintain
- scripts may end up scattered across pages, templates, and code blocks
- later you may forget where a certain animation was added
-
dependency/order issues
- if your custom script runs before GSAP is loaded, it breaks
- if
ScrollTriggeris loaded after your code, it breaks
-
not ideal for larger projects
- many pages with animation become messy
- updating versions across many pages becomes annoying
-
possible duplication
- you might accidentally load GSAP multiple times
- that can lead to confusion or performance issues
when to use it
Use this method if:
- you are just learning
- you want to test a small animation quickly
- you are building a simple one-page effect
- you are not yet ready to work with theme files or enqueue functions
when not to use it
Avoid relying on this as your long-term default if:
- your site has many animated pages
- you want a clean, scalable setup
- you work on client projects that need easier maintenance
- you want centralized control over scripts
practical recommendation
For a beginner in BricksBuilder, this is an excellent sandbox method. Learn here first. But do not assume it is always the best production architecture.
method 2: adding GSAP properly via WordPress enqueueing
This is the WordPress-native way, and in many cases the best long-term solution ✅
WordPress has a built-in system for loading CSS and JavaScript files called enqueueing. Instead of manually printing <script> tags wherever you want, you tell WordPress which scripts to load, and WordPress handles output and ordering more cleanly.
why enqueueing matters
When scripts are enqueued properly, WordPress can better manage:
- dependencies
- load order
- footer vs header loading
- conditional loading
- conflicts with themes/plugins
This makes your setup more robust.
a basic example
You would typically add this to your theme’s functions.php file, or better, to a child theme:
function mytheme_enqueue_gsap() {
wp_enqueue_script(
'gsap',
'https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js',
array(),
'3.12.5',
true
);
wp_enqueue_script(
'gsap-scrolltrigger',
'https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js',
array('gsap'),
'3.12.5',
true
);
wp_enqueue_script(
'my-gsap-animations',
get_stylesheet_directory_uri() . '/js/animations.js',
array('gsap', 'gsap-scrolltrigger'),
'1.0',
true
);
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_gsap');
Your custom animation code would then live in a separate file, for example /js/animations.js:
gsap.registerPlugin(ScrollTrigger);
gsap.to(".box", {
scrollTrigger: ".box",
y: 100,
duration: 1
});
what this code means
Let’s unpack it carefully:
-
wp_enqueue_script(...)- tells WordPress to load a JavaScript file
-
'gsap'- this is the script handle
- WordPress uses it as an internal name
-
'https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js'- this is the file URL
-
array()- this means GSAP core has no dependency in this setup
-
'3.12.5'- this is the version string
- useful for cache-busting and clarity
-
true- load in the footer
- generally good for performance and safer for DOM-related code
For ScrollTrigger, this line matters a lot:
array('gsap')
That tells WordPress:
“Load
ScrollTriggeronly aftergsaphas loaded.”
And here:
array('gsap', 'gsap-scrolltrigger')
you tell WordPress:
“Load my animation file only after both GSAP core and ScrollTrigger are available.”
That is one of the biggest advantages of enqueueing.
advantages
-
cleaner structure
- GSAP loading is centralized
- your animation logic lives in its own file
-
better dependency management
- WordPress handles load order
- fewer “gsap is not defined” errors
-
more scalable
- better for larger sites
- better for reusable workflows
- better for client projects
-
easier maintenance
- update a version in one place
- update one JS file instead of many inline snippets
-
closer to professional practice
- this is the way many developers structure scripts in WordPress
disadvantages
-
requires some PHP
- even if only a little
- this may feel intimidating at first
-
slower to set up initially
- compared to just pasting script tags into a page
-
you need file access
- child theme
- theme editor
- SFTP or hosting file manager
- a code snippets workflow that supports this logic
when to use it
This is ideal if:
- you want a solid long-term setup
- you animate across multiple pages
- you want your code to stay organized
- you are ready to learn a little WordPress development structure
important best practice: use a child theme
If you place code directly in a parent theme and later update the theme, your changes may be overwritten. 😬
So if you are editing functions.php, it is usually safer to do so in a child theme.
conditional loading
A very useful improvement is to load GSAP only on pages that actually need it.
Example:
function mytheme_enqueue_gsap() {
if (!is_page('landing-page')) {
return;
}
wp_enqueue_script(
'gsap',
'https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js',
array(),
'3.12.5',
true
);
wp_enqueue_script(
'my-gsap-animations',
get_stylesheet_directory_uri() . '/js/landing-page-animations.js',
array('gsap'),
'1.0',
true
);
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_gsap');
This means:
- if the current page is not
landing-page, stop immediately - otherwise, load GSAP and your animation file
This is cleaner than loading everything site-wide when only one page needs it.
method 3: adding GSAP through a code snippets plugin or script management plugin
This is a kind of middle ground between “quick and easy” and “properly structured.” ⚖️
Instead of editing theme files manually, you use a plugin that lets you insert PHP, JavaScript, or site-wide scripts in a managed interface.
Examples of plugin categories:
- Code Snippets plugins
- Header/Footer script plugins
- asset/script manager plugins
- some advanced custom code manager plugins
how this works
There are two main variations:
- you insert raw
<script>tags globally - you add PHP that uses
wp_enqueue_script()
The second is generally better if the plugin supports PHP snippets safely.
example: enqueueing GSAP through a snippets plugin
function mysite_enqueue_gsap() {
wp_enqueue_script(
'gsap',
'https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js',
array(),
'3.12.5',
true
);
wp_enqueue_script(
'gsap-scrolltrigger',
'https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js',
array('gsap'),
'3.12.5',
true
);
}
add_action('wp_enqueue_scripts', 'mysite_enqueue_gsap');
Then you might place your custom JS:
- in a separate JS file
- in a page-level code area
- in another snippet/plugin field depending on the plugin
why this is attractive
For many WordPress users, especially non-developers, this is easier because:
- no theme file editing is required
- your custom code survives theme updates
- plugin interfaces can be less intimidating than file editing
advantages
-
safer than editing parent theme files
- theme updates are less risky
-
often easier for non-developers
- no SFTP required
- no direct file management required
-
can still be fairly organized
- especially if the plugin supports named snippets
- you can label snippets clearly
-
good transition step
- excellent if you are learning WordPress development concepts gradually
disadvantages
-
depends on another plugin
- more plugin dependency
- plugin settings differ from tool to tool
-
can still become messy
- if you store too many unrelated scripts in too many snippets
-
sometimes less transparent
- another developer may need to search plugins to find your script setup
-
not always ideal for larger development workflows
- especially if you later move toward version-controlled theme/project files
when to use it
This is a strong option if:
- you don’t want to edit theme files yet
- you want something more maintainable than random page-level script tags
- you are comfortable managing code in a plugin interface
- you want a relatively safe setup on client sites
a very practical beginner-friendly approach
A nice compromise can be:
- enqueue GSAP and plugins globally or conditionally via a snippets plugin
- keep small page-specific animation code inside Bricks where it is used
- move larger animation code into separate JS files later
That way, your library loading is centralized, but your small experiments remain easy to work with.
method 4: bundling GSAP in a custom theme or child theme workflow
This is the most “developer-style” approach and often the cleanest for serious projects 🛠️
Instead of relying on CDN links everywhere, you may keep your scripts in your project structure and load them through your theme or build process.
what this can mean
This can range from relatively simple to quite advanced:
- storing your own custom JS files inside the theme
- enqueueing local copies of GSAP files
- using a build tool or bundler
- organizing animations into modules/files
For your current level, you probably do not need the advanced version yet. But it is good to understand the direction.
local file example
Suppose you store GSAP files inside your child theme:
/js/vendor/gsap.min.js/js/vendor/ScrollTrigger.min.js/js/animations.js
Then enqueue them:
function mytheme_enqueue_local_gsap() {
wp_enqueue_script(
'gsap',
get_stylesheet_directory_uri() . '/js/vendor/gsap.min.js',
array(),
'3.12.5',
true
);
wp_enqueue_script(
'gsap-scrolltrigger',
get_stylesheet_directory_uri() . '/js/vendor/ScrollTrigger.min.js',
array('gsap'),
'3.12.5',
true
);
wp_enqueue_script(
'my-animations',
get_stylesheet_directory_uri() . '/js/animations.js',
array('gsap', 'gsap-scrolltrigger'),
'1.0',
true
);
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_local_gsap');
CDN vs local file: what is the difference?
With a CDN:
- files are loaded from an external server
With local files:
- files are served from your own site/theme
Neither is automatically “always better.” It depends on priorities.
CDN advantages
- quick to set up
- easy to update URL versions
- no need to manage local vendor files manually
local file advantages
- more project control
- less dependence on third-party external URLs
- easier to version together with the project files
- often preferable in structured development workflows
disadvantages of a custom theme workflow
- more setup complexity
- requires more confidence with file structure
- may involve build tooling later
- can feel like overkill for small sites
when to use it
Use this if:
- you build custom WordPress sites regularly
- you want a reusable professional workflow
- you manage code in a structured way
- you may later adopt Git/version control and more advanced JS organization
method 5: loading GSAP only where Bricks needs it
This is not a totally separate technical method, but rather an important strategy for WordPress + BricksBuilder projects.
A common beginner mistake is:
- load GSAP everywhere
- put all animation logic in one giant script
- target many classes globally
- lose track of what affects what
A better approach is often:
- load the library globally or conditionally
- keep animation code grouped by template/page/component
- use consistent classes and naming
For example:
- one JS file for hero animations
- one JS file for scroll sections
- one JS file for reusable components like sliders/cards
- or one main file with clearly separated sections
This becomes especially useful in Bricks because Bricks encourages visual building, and without structure your JS can become hard to map back to the layout.
a realistic comparison of the methods
Here is the practical comparison in plain language:
-
CDN directly in page/template
- best for: learning, testing, small one-off effects
- weakest point: maintenance becomes messy
-
WordPress enqueueing in theme/child theme
- best for: long-term clean setup
- weakest point: requires some PHP confidence
-
code snippets/plugin-based loading
- best for: users who want structure without editing theme files
- weakest point: still plugin-dependent and can become messy if overused
-
custom theme/local asset workflow
- best for: advanced or growing professional projects
- weakest point: more setup complexity
If I were advising someone with limited JS/CSS skills but who wants to learn properly, I would suggest this progression:
- start with page-level CDN loading to understand GSAP basics
- then move to snippet/plugin-based enqueueing
- then learn child theme enqueueing
- later, if needed, adopt a more structured local/bundled workflow
That learning path keeps your cognitive load manageable. 🧠
important technical details you should understand regardless of method
No matter which loading method you choose, a few concepts always matter.
1. load order
Your custom GSAP code must run after GSAP is available.
Bad order:
- your animation code runs
- GSAP loads afterward
Result: error such as gsap is not defined
Good order:
- GSAP core loads
- GSAP plugin loads
- your custom animation code runs
2. plugin registration
Some GSAP plugins should be registered before use:
gsap.registerPlugin(ScrollTrigger);
If you forget this, your scroll-based animations may not work correctly.
3. DOM readiness
Even if GSAP is loaded correctly, the elements you want to animate must also exist when your code runs.
For example, this may fail if .box is not yet in the DOM at execution time:
gsap.to(".box", {
x: 200
});
A safer beginner pattern is:
document.addEventListener("DOMContentLoaded", function () {
gsap.to(".box", {
x: 200,
duration: 1
});
});
This says:
- wait until the HTML document has loaded
- then run the animation code
This is especially useful in WordPress because page builders, templates, and dynamic content can make script timing less obvious.
4. page builders can change markup
With BricksBuilder, what you see visually is tied to generated HTML. If you later change:
- a class name
- a nested structure
- a template assignment
your GSAP selector may stop matching.
So this selector:
gsap.to(".hero-title", {
y: 50
});
only works if an element with class .hero-title still exists on the front end.
That is why consistent class naming is very important.
5. avoid loading the same library multiple times
This is a surprisingly common issue.
For example:
- GSAP loaded in a header/footer plugin
- GSAP loaded again in Bricks custom code
- GSAP loaded a third time in
functions.php
This can create debugging confusion. Even if it does not always break visibly, it is bad practice.
Try to keep a clear answer to the question:
“Where exactly is GSAP being loaded on this site?”
If you cannot answer that in one sentence, your setup may already be getting messy.
recommended setups for different skill levels
if you are an absolute beginner
Use:
- CDN + page-level script
- maybe inside a Bricks code block or page custom code area
Why:
- fastest feedback loop
- easiest for learning syntax
- minimal setup complexity
But keep it limited to experiments.
if you are a beginner who wants a cleaner real-site setup
Use:
- a Code Snippets-style plugin to enqueue GSAP
- a separate custom JS file if possible
- small page-specific code only where needed
Why:
- safer than editing theme files too early
- more maintainable than scattered inline scripts
- good stepping stone toward proper development practice
if you are building more serious projects
Use:
- child theme enqueueing
- separate JS files
- conditional loading where sensible
- clear naming conventions for Bricks elements
Why:
- cleaner architecture
- easier maintenance
- better scalability
recommended setup specifically for WordPress + BricksBuilder learners
For your situation, I would recommend the following staged approach:
-
phase 1: learn GSAP with the simplest possible setup
- load GSAP via CDN
- paste small scripts into a controlled test page in Bricks
- animate simple classes like
.box,.title,.button
-
phase 2: centralize library loading
- move GSAP loading into a snippet/plugin-based global setup
- stop loading the library individually on every test page
-
phase 3: separate your animation logic
- move your custom animations into a JS file
- keep the file organized by section or component
- use comments to mark each animation area
-
phase 4: move to child theme enqueueing when you feel ready
- this gives you a more professional workflow
- especially useful for client work or bigger sites
This sequence is effective because it respects the idea that learning has a kind of “cost function” 😊
If we think of setup difficulty as $D$ and learning benefit as $B$, then for beginners you want a method where the ratio $\frac{B}{D}$ is as high as possible. Early on, simple setups often give better returns; later, cleaner architecture becomes more valuable.
a simple decision guide
If you are unsure which method to choose, use this rule of thumb:
-
I just want to test GSAP today
- use CDN in the page/template
-
I want a safer no-theme-edit workflow
- use a snippets/plugin approach
-
I want a clean long-term WordPress setup
- use child theme enqueueing
-
I build structured custom projects
- use a custom theme/local asset workflow
common mistakes to avoid
- putting GSAP code before the library is loaded
- forgetting to load or register plugins like
ScrollTrigger - animating selectors that do not exist on the front end
- loading GSAP multiple times from different places
- storing too much important logic in scattered inline scripts
- editing a parent theme directly
- not checking whether scripts should load globally or only on specific pages
my practical recommendation in one sentence
For learning, start with CDN + simple page-level code; for real projects, move as soon as possible toward centralized loading via snippets or child-theme enqueueing. ✅