Skip to content

Instantly share code, notes, and snippets.

@gregrickaby
Last active November 26, 2024 23:20
Show Gist options
  • Save gregrickaby/2846416 to your computer and use it in GitHub Desktop.
Save gregrickaby/2846416 to your computer and use it in GitHub Desktop.

Revisions

  1. gregrickaby revised this gist Nov 10, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion remove-woocommerce-styles-scripts.php
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,8 @@ function grd_woocommerce_script_cleaner() {
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_style( 'select2' );
    wp_dequeue_script( 'selectWoo' );
    wp_deregister_script( 'selectWoo' );
    wp_dequeue_script( 'wc-add-payment-method' );
    wp_dequeue_script( 'wc-lost-password' );
    wp_dequeue_script( 'wc_price_slider' );
  2. gregrickaby revised this gist May 25, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions remove-woocommerce-styles-scripts.php
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@ function grd_woocommerce_script_cleaner() {
    // Remove the generator tag
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );

    // If we're on the homepage, remove all the cruft!
    if ( is_front_page() || is_home() ) {
    // Unless we're in the store, remove all the cruft!
    if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce-general');
    wp_dequeue_style( 'woocommerce-layout' );
  3. gregrickaby revised this gist May 25, 2015. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions remove-woocommerce-styles-scripts.php
    Original file line number Diff line number Diff line change
    @@ -12,13 +12,20 @@ function grd_woocommerce_script_cleaner() {
    // If we're on the homepage, remove all the cruft!
    if ( is_front_page() || is_home() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce-general');
    wp_dequeue_style( 'woocommerce-layout' );
    wp_dequeue_style( 'woocommerce-smallscreen' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_style( 'select2' );
    wp_dequeue_script( 'wc-add-payment-method' );
    wp_dequeue_script( 'wc-lost-password' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'wc-single-product' );
    wp_dequeue_script( 'wc-add-to-cart' );
    wp_dequeue_script( 'wc-cart-fragments' );
    wp_dequeue_script( 'wc-credit-card-form' );
    wp_dequeue_script( 'wc-checkout' );
    wp_dequeue_script( 'wc-add-to-cart-variation' );
    wp_dequeue_script( 'wc-single-product' );
    @@ -29,6 +36,7 @@ function grd_woocommerce_script_cleaner() {
    wp_dequeue_script( 'prettyPhoto-init' );
    wp_dequeue_script( 'jquery-blockui' );
    wp_dequeue_script( 'jquery-placeholder' );
    wp_dequeue_script( 'jquery-payment' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }
  4. gregrickaby renamed this gist May 25, 2015. 1 changed file with 0 additions and 0 deletions.
  5. gregrickaby renamed this gist May 25, 2015. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions functions.php → remove-woocommerc-styles-scripts.php
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
    <?php
    //* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php

    /**
    * Remove WooCommerce Generator tag, styles, and scripts from the homepage.
    * Tested and works with WooCommerce 2.0+
    *
    * @author Greg Rickaby
    * @since 2.0.0
    * Manage WooCommerce styles and scripts.
    */
    function child_manage_woocommerce_styles() {
    function grd_woocommerce_script_cleaner() {

    // Remove the generator tag
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );

    // If we're on the homepage, remove all the cruft!
    if ( is_front_page() || is_home() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    @@ -29,4 +31,6 @@ function child_manage_woocommerce_styles() {
    wp_dequeue_script( 'jquery-placeholder' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }}
    }
    }
    add_action( 'wp_enqueue_scripts', 'grd_woocommerce_script_cleaner', 99 );
  6. gregrickaby revised this gist Apr 22, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    */
    function child_manage_woocommerce_styles() {
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
    if ( is_front_page() || is_home() ) {
    if ( is_front_page() || is_home() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
  7. gregrickaby revised this gist Apr 22, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
    /**
    * Remove WooCommerce Generator tag, styles, and scripts unless inside the store.
    * Remove WooCommerce Generator tag, styles, and scripts from the homepage.
    * Tested and works with WooCommerce 2.0+
    *
    * @author Greg Rickaby
    * @since 2.0.0
    */
    function child_manage_woocommerce_styles() {
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
    if ( 'product' !== get_post_type() && !is_page( 'shop' ) && !is_page( 'cart' ) && !is_page( 'checkout' ) && !is_page( 'my-account' ) ) {
    if ( is_front_page() || is_home() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
  8. gregrickaby revised this gist Apr 22, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,13 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    * Remove WooCommerce Generator tag, styles, and scripts unless inside the store.
    * Tested and works with WooCommerce 2.0+
    *
    * @author Greg Rickaby
    * @since 2.0.0
    */
    function child_manage_woocommerce_styles() {
    remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
    if ( 'product' !== get_post_type() && !is_page( 'shop' ) && !is_page( 'cart' ) && !is_page( 'checkout' ) && !is_page( 'my-account' ) ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
  9. gregrickaby revised this gist Apr 22, 2013. 1 changed file with 17 additions and 5 deletions.
    22 changes: 17 additions & 5 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,31 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woo_styles', 99 );
    add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    * Tested and works with WooCommerce 1.0+ and 2.0+
    * Tested and works with WooCommerce 2.0+
    *
    * @author Greg Rickaby
    * @since 1.1.0
    * @since 2.0.0
    */
    function child_manage_woo_styles() {
    if ( 'product' !== get_post_type() && !is_page( 'cart' ) && !is_page( 'checkout' ) ) {
    function child_manage_woocommerce_styles() {
    if ( 'product' !== get_post_type() && !is_page( 'shop' ) && !is_page( 'cart' ) && !is_page( 'checkout' ) && !is_page( 'my-account' ) ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'wc-single-product' );
    wp_dequeue_script( 'wc-add-to-cart' );
    wp_dequeue_script( 'wc-cart-fragments' );
    wp_dequeue_script( 'wc-checkout' );
    wp_dequeue_script( 'wc-add-to-cart-variation' );
    wp_dequeue_script( 'wc-single-product' );
    wp_dequeue_script( 'wc-cart' );
    wp_dequeue_script( 'wc-chosen' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'prettyPhoto' );
    wp_dequeue_script( 'prettyPhoto-init' );
    wp_dequeue_script( 'jquery-blockui' );
    wp_dequeue_script( 'jquery-placeholder' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }}
  10. gregrickaby revised this gist Mar 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woo_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    * Works with WooCommerce 2.0+
    * Tested and works with WooCommerce 1.0+ and 2.0+
    *
    * @author Greg Rickaby
    * @since 1.1.0
  11. gregrickaby revised this gist Mar 27, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,9 @@ function child_manage_woo_styles() {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }}
  12. gregrickaby revised this gist Mar 27, 2013. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,10 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_woo_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    * Works with WooCommerce 2.0+
    *
    * @author Greg Rickaby
    * @since 1.0.0
    * @since 1.1.0
    */
    function child_manage_woo_styles() {
    if ( 'product' !== get_post_type() && !is_page( 'cart' ) && !is_page( 'checkout' ) ) {
    @@ -12,6 +13,7 @@ function child_manage_woo_styles() {
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    // wp_dequeue_script( 'fancybox' ); Not using fancybox? Then uncomment this line!
    // wp_dequeue_script( 'jqueryui' ); Not using jquery-ui? Then uncomment this line!
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }}
  13. gregrickaby revised this gist May 31, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    * @since 1.0.0
    */
    function child_manage_woo_styles() {
    if ( 'product' !== get_post_type() && !is_page( 'cart' ) ) {
    if ( 'product' !== get_post_type() && !is_page( 'cart' ) && !is_page( 'checkout' ) ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
  14. gregrickaby revised this gist May 31, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    * @since 1.0.0
    */
    function child_manage_woo_styles() {
    if ( 'product' !== get_post_type() ) {
    if ( 'product' !== get_post_type() && !is_page( 'cart' ) ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
  15. gregrickaby revised this gist May 31, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ function child_manage_woo_styles() {
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    // wp_dequeue_script( 'fancybox' ); Not using fancybox? Then un-comment this line!
    // wp_dequeue_script( 'jqueryui' ); Not using jquery-ui? Then un-comment this line!
    // wp_dequeue_script( 'fancybox' ); Not using fancybox? Then uncomment this line!
    // wp_dequeue_script( 'jqueryui' ); Not using jquery-ui? Then uncomment this line!
    }}
  16. gregrickaby revised this gist May 31, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ function child_manage_woo_styles() {
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    // wp_dequeue_script( 'fancybox' ); if you're using fancybox un-comment this line
    // wp_dequeue_script( 'jqueryui' ); if you're using jqueryui un-comment this line
    // wp_dequeue_script( 'fancybox' ); Not using fancybox? Then un-comment this line!
    // wp_dequeue_script( 'jqueryui' ); Not using jquery-ui? Then un-comment this line!
    }}
  17. gregrickaby revised this gist May 31, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ function child_manage_woo_styles() {
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    // wp_dequeue_script( 'fancybox' ); if you're using fancybox un-comment this line
    // wp_dequeue_script( 'jqueryui' ); if you're using jqueryui un-comment this line
    }}
  18. gregrickaby revised this gist May 31, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_styles', 99 );
    add_action( 'wp_enqueue_scripts', 'child_manage_woo_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    *
    * @author Greg Rickaby
    * @since 1.0.0
    */
    function child_manage_styles() {
    function child_manage_woo_styles() {
    if ( 'product' !== get_post_type() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
  19. gregrickaby created this gist May 31, 2012.
    17 changes: 17 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    add_action( 'wp_enqueue_scripts', 'child_manage_styles', 99 );
    /**
    * Remove WooCommerce styles and scripts unless inside the store.
    *
    * @author Greg Rickaby
    * @since 1.0.0
    */
    function child_manage_styles() {
    if ( 'product' !== get_post_type() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
    }}