Breakdance allows you to modify dependencies using various hooks and filters. This may be useful for hosting files locally or changing the version of a dependency.
Append Dependencies Filter
The
breakdance_append_dependencies filter can be used to modify or remove dependencies. Information on this filter may be found here:
https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md.
Reusable Dependencies
You can use the
breakdance_reusable_dependencies_urls action to change the version or path of a reusable dependency in Breakdance. This is useful for adding new dependencies or converting some dependencies to be local only. More information about this action may be found here:
https://github.com/soflyy/breakdance-developer-docs/blob/master/reusable-dependencies/readme.md.
Example: Replacing GSAP Dependencies
The following example shows how to replace GSAP Dependencies:
- Download GSAP: https://gsap.com/docs/v3/Installation.
- Unzip the folder
- Go to gsap-public and upload the “gsap.min.js” and “ScrollTrigger.min.js” files to your server. For example, you can upload it to “/wp-content/uploads/local.
- Add the following code to your site using your preferred code snippets plugin:
<?php
add_action('breakdance_reusable_dependencies_urls', function ($urls) {
$urls['gsap'] = '/path/to/file/gsap.min.js';
$urls['scrollTrigger'] = '/path/to/file/ScrollTrigger.min.js';
return $urls;
});