hooks – “Intercept” enqueing of 3rd party’s JS file

Question

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?

0
Faye D. 7 months 2022-01-08T22:07:19-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse