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 );
3 Comments
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’);
}
}
Very nice! You (and Google) saved me from boring documentation reading!
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!