Disable WP E-Commerce scripts and stylesheets

This comes straight outta the getShopped forums: http://getshopped.org/forums/topic/disable-all-wpsc-javascript-and-css-files-3/ via cannobbio.

To disable all scripts and stylesheets, add this code to the functions.php file in your theme folder:


// Remove Styles
function childtheme_deregister_styles() {
wp_deregister_style( 'wpsc-theme-css' );
wp_deregister_style( 'wpsc-theme-css-compatibility' );
wp_deregister_style( 'wpsc-product-rater' );
wp_deregister_style( 'wp-e-commerce-dynamic');
wp_deregister_style( 'wpsc-thickbox' );
wp_deregister_style( 'wpsc-gold-cart' );
}
add_action( 'wp_print_styles', 'childtheme_deregister_styles', 100 );

// Remove Scripts
function childtheme_deregister_scripts() {
wp_deregister_script( 'wpsc-thickbox' );
wp_deregister_script( 'jquery-rating' );
wp_deregister_script( 'wp-e-commerce' );
wp_deregister_script( 'jQuery' );
wp_deregister_script( 'infieldlabel' );
wp_deregister_script( 'wp-e-commerce-ajax-legacy' );
wp_deregister_script( 'wp-e-commerce-dynamic' );
wp_deregister_script( 'livequery' );
wp_deregister_script( 'wp-e-commerce-legacy' );
wp_deregister_script( 'l10n' );
wp_deregister_script( 'wpsc-gold-cart' );
}
add_action( 'wp_print_scripts', 'childtheme_deregister_scripts', 100 );

// Remove Product List RSS
remove_action('wp_head', 'wpsc_product_list_rss_feed');

Then expect things to get weird! This will disable a lot of built-in functionality which you prolly want. Fortunately you can easily pick and choose by leaving out the scripts and stylesheets you still need. I found that the most disruptive thing for my customisations was the Gold Cart stylesheet, which I disabled with this:


// Remove gold cart css
function childtheme_deregister_styles() {
wp_deregister_style( 'wpsc-gold-cart' );
}
add_action( 'wp_print_styles', 'childtheme_deregister_styles', 100 );

This entry was posted in Solutions and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Posted August 24 2011 at 5:16 pm | Permalink

    This also does the trick but you can’t use conditional tags (e.g: apply only on specific page)

    add_action(‘init’, ‘filter_wpsc_script’, 5);
    function filter_wpsc_script(){
    if(function_exists(‘wpsc_the_product’)) {
    remove_action(‘init’, ‘wpsc_enqueue_user_script_and_css’);
    }
    }

  2. Posted November 21 2011 at 9:43 am | Permalink

    Very nice! You (and Google) saved me from boring documentation reading!

  3. Justin
    Posted December 16 2011 at 5:37 am | Permalink

    great post! i hate how many scripts/styles they include and couldnt figure out how to stop it without editing the source files. really kills my pagespeed score. combining all the neccessary ones into single docs, minifying & gzipping FTW. =)

    thank you!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>