[ad_1]
I’m looking for advice on the best way to integrate gsap on my WordPress site. I have gsap loaded up through my child theme and was able to get some basic animations going by just putting some blocks on a page with some additional css classes and selecting those classes in my gsap js file, but I’m not sure if this is the best way to go about this. Any insight/advice would be appreciated!
[ad_2]
Child theme or plugin would be an appropriate place to hook or add functionality. You can then add components, blocks, shortcodes, etc. in the child theme or plugin. Give yourself a nice little SCSS/JS frontend workflow with node, webpack (or alternatives), and load in your packages (gasp, etc) via NPM (I like pnpm).
I always always always recommend maintaining your changes with a proper fit workflow too. Plugins make that simpler because you can package small purpose-built changes and deploy/release quickly. Though, maintaining a child theme package would be beneficial for wider testing suites and more stable deployments if those animated components are a larger part of the design.
Just a few choices to make, but you’re definitely on the right track.
I maintain the GSAP integration via a plugin, so it isn’t theme dependent. To be fair though, I wrote the plugin so it’s easy to maintain and get support.
But then, whatever you need to target should be getting wrapped in unique custom classes/ids. This way, if the dev team of the parent theme ever swaps classes on you, and they will at some point, your functions aren’t broken.