Skip to content

Instantly share code, notes, and snippets.

@mishterk
Last active December 10, 2023 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishterk/c21ef532f78f9fc9f8c5ae4ec71593bc to your computer and use it in GitHub Desktop.
Save mishterk/c21ef532f78f9fc9f8c5ae4ec71593bc to your computer and use it in GitHub Desktop.
This script replaces Breakdance's GSAP script URLs using a data URI scheme with a base64 encoded empty string which represents an empty JS file. This effectively removes Breakdance's copy of GSAP allowing third parties like Motion.page to load their version of it without conflict.

Disable Breakdance GSAP assets

This can be used to disable the GSAP scripts in Breakdance when something like Motion.page needs to be used instead. Motion.page and Breakdance both load the same scripts with different versions and this causes Motion.page's scrollTrigger feature to fail. I found this when using a Breakdance popup with animations on entry and exit.

This snippet comes with no support or guarantee so use at your own risk. If you do use it, feel free to comment below with any findings for others to consider.

Caveats

This is site wide and without some conditional loading, will result in GSAP not loading at all on pages where Motion.page isn't running an animation timeline. For this reason, it should be used conditionally on pages where Motion.page is running.

Note that checking whether Motion.page's scripts have been enqueued inside the callback always returns FALSE due to the timing of the filter offered by Breakdance.

<?php
add_filter( 'breakdance_reusable_dependencies_urls', function ( $urls ) {
$urls['gsap'] = 'data:text/javascript;base64,';
$urls['scrollTrigger'] = 'data:text/javascript;base64,';
return $urls;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment