WordPress and wp_deregister_script

I am trying to prevent all of the different scripts from my shop ( jigoshop ) from loading on every page load. I have been using the wp_deregister_script function but it wont work. My question is, if there is a way that the wp_deregister_script function could be blocked by the plugin itself or any other function?

This is the script i am currently using:

function js_css_control() 
{
    $link = $_SERVER['REQUEST_URI'];
    $teile = explode("/", $link);
    if($link!="/")
    {
        $seite = $teile[1];
    }
    else
    {
        $seite = "start";
    }
    if($seite=="start")
    {
        wp_deregister_script( 'jigoshop_global' ); 
        wp_deregister_script( 'prettyPhoto' );  
        wp_deregister_style ( 'jigoshop_styles' );
        wp_deregister_style ( 'jigoshop-jquery-ui' );
        wp_deregister_style ( 'jigoshop-select2' );     
    }
}
add_action('wp_enqueue_scripts', 'js_css_control');

Related posts

1 comment

  1. The function that may suit your purpose better is wp_dequeue_script. You can do everything just about the same except change deregister to dequeue.

    Also, if that doesn’t work and for future reference, try changing the hook that you use in add_action, for instance template_redirect may be a choice in case wp_enqueue_scripts doesn’t pan out.

Comments are closed.