Jump to content
Search Community

ScrollTrigger crashes WordPress admin editor scripts when imported from node modules

Damien Chantelouve
Moderator Tag

Recommended Posts

Damien Chantelouve
Posted

Hi o/

I'm making this post mainly for reference to maybe help some others users which might encounter this issue (and also maybe for you GSAP).

I did read the article / documentation about how to integrate GSAP into WordPress using WordPress methods which is a good thing but most devs build / handle directly their assets using a bundler and enqueue only their final build.

As of right now (WordPress 6.6 / 6.7), if you use GSAP ScrollTrigger from import / node_modules (the CDN version works fine), and if you enqueue your final js build in editor hooks like "enqueue_block_editor_assets", it will break WordPress admin editor javascript somehow (i think it's related to some global variable clash) and result in a white screen mostly and a lot of console errors (see screenshots below)

Code :
image.thumb.png.c438b3bd7e464d1e7f1dc7588d39407c.png
WordPress admin "New post" page:
image.thumb.png.2e730097a8b0c58ebcfecc66ea4f5e4b.png

The fix load GSAP ScrollTrigger out of your js build using wp_enqueue_script and before enqueueing your js build using the same WordPress function (see how to load it correctly here)

Hope this can help

Have a good day,
Damien

  • Thanks 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...