hooks – “Intercept” enqueing of 3rd party’s JS file
I’m using a 3rd-party plugin, but I need to load the non-minified version of a specific JS file of the plugin, to avoid some image preloading caching; in the AJAX call when preloading some images, the minified JS uses param cache:!0
that breaks a specific functionality that I need…
So, the relevant code in the plugin reads:
wp_enqueue_script( 'woo-variation-gallery', esc_url( $this->assets_uri( "/js/frontend{$suffix}.js" ) ), array(
'jquery',
'wp-util',
'woo-variation-gallery-slider',
'imagesloaded',
'wc-add-to-cart-variation'
), $this->version(), true );
where $suffix
is calculated a little above (that’s pretty standard in every plugin basically) like this:
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
So, temporarily I got around this by setting SCRIPT_DEBUG
to true
in my wp-config.php, but it doesn’t feel right loading non-minified scripts site-wide just for a single script that needs to be loaded in its non-minified version…
So, is there any hook involved while enqueuing scripts, to hook into in my functions.php file in order to replace the script’s $src
from the plugin’s /js/frontend.min.js
to /js/frontend.min.js
before loading it?
Leave an answer