admin管理员组

文章数量:1325522

I got one plugin which generates all CSS and JS on the /wp-content/uploads/xyz-folder, I want to disable all this CSS and JS load on my website page.

Is it possible?

I got one plugin which generates all CSS and JS on the /wp-content/uploads/xyz-folder, I want to disable all this CSS and JS load on my website page.

Is it possible?

Share Improve this question asked Aug 1, 2020 at 16:28 abid_hasan112abid_hasan112 11 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 1

If you know what the names of the handles that the plugins use are, you can locate them using this code and then just use a simple wp_dequeue_script function.

function wp_inspect_scripts() {
    global $wp_scripts;
    echo '<pre><h1>Script Handles</h1><ul>';
    foreach( $wp_scripts->queue as $handle ) :
        echo '<li>' . $handle . '</li>';
    endforeach;
    echo '</ul></pre>';
}
add_action( 'wp_print_scripts', 'wp_inspect_scripts' );

function wp_inspect_styles() {
    global $wp_styles;
    echo '<pre><h1>Style Handles</h1><ul>';
    foreach( $wp_styles->queue as $handle ) :
        echo '<li>' . $handle . '</li>';
    endforeach;
    echo '</ul></pre>';
}
add_action( 'wp_print_styles', 'wp_inspect_styles' );

Add the above code to your themes functions.php file for this to work.

If the plugin dynamically generates script and style handles so that you can't use wp_dequeue_script and wp_dequeue_style, as you said in a comment on another answer, then you would need to fork the plugin, and remove the section of code that is doing that, or else wrap it in a conditional so that it only loads on the specific page in question. (Fork, because your changes will be overwritten by the next plugin update).

本文标签: functionsWant to dequeue all the CSS and JS from wpcontentuploadsxyzfolder