Title: Remove Plugin Action on Certain Pages
Last modified: July 29, 2020

---

# Remove Plugin Action on Certain Pages

 *  Resolved [bbrophy](https://wordpress.org/support/users/bbrophy/)
 * (@bbrophy)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/)
 * Hi, this plugin is installed on a site I’m working on. I’d like to stop the scripts
   from loading on certain pages (i.e., those without a plugin shortcode). I’ve 
   tried this inside and outside my conditional, but with no luck:
 * remove_action( ‘wp_enqueue_scripts’, array(‘google_business_reviews_rating’, ‘
   wp_js_load’) );
 * This is based on the plugin’s index.php file. Not sure if anyone has any tips–
   thanks!
 * The scripts are ultimately being delivered minified and combined via wp fastest
   cache – not sure if that matters.
    -  This topic was modified 5 years, 10 months ago by [bbrophy](https://wordpress.org/support/users/bbrophy/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Noah Hearle](https://wordpress.org/support/users/designextreme/)
 * (@designextreme)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13187990)
 * [@bbrophy](https://wordpress.org/support/users/bbrophy/) I’ll send something 
   through shortly to cover this.
 * A recommendation: why not use a caching/compression plugin to serve all scripts
   as one file – then it will load once per visit and save on the load time throughout
   the website?
 *  Plugin Author [Noah Hearle](https://wordpress.org/support/users/designextreme/)
 * (@designextreme)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13189714)
 * [@bbrophy](https://wordpress.org/support/users/bbrophy/) After a little look 
   at the documentation and in forums, the unloading of this script is not possible
   with this method. The class is not referred to by name as you listed in your 
   example.
 * I may add something in the future to look for pages/posts containing the shortcode
   and then onload load the JavaScript and style sheet in these pages. It’s not 
   as straight-forward as I would like.
 * May I ask why you want to do this on your website? Is it because of load times
   or a conflict with the theme or another plugin?
 *  Thread Starter [bbrophy](https://wordpress.org/support/users/bbrophy/)
 * (@bbrophy)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13190441)
 * I’m just going through and trying to optimize script and stylesheet loading across
   the site (e.g., code splitting, conditionally loading Contact Form 7 scripts).
   If it’s not possible, no worries. I thought that might be the case.
 * Some people said that you can only remove_action on class object instances saved
   to a variable. Others said that you should be able to just to use the class name
   if it wasn’t saved to a variable, but that doesn’t seem to work. Anyway, cheers!
   Appreciate you taking the time.
 *  Plugin Author [Noah Hearle](https://wordpress.org/support/users/designextreme/)
 * (@designextreme)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13191144)
 * [@bbrophy](https://wordpress.org/support/users/bbrophy/) That’s ok, it’s always
   good to ask!
 * With the site optimisation, if you can have all the theme and plugin scripts 
   load in a compressed form as just one file, that’s the most effective way to 
   reduce load time. If there are slightly different consolidated scripts across
   the website, you won’t be taking advantage of it already being cached by the 
   browser (reducing the footprint to near-zero). It does depend upon the website
   to some degree.
 * Also, this plugin’s script file is pretty small even uncompressed so having it
   load once per visit isn’t going to have a noticeable effect.
 * One consideration, if reducing load time is vital: choose to hide the author 
   avatars or set these to one local image.
 *  Plugin Author [Noah Hearle](https://wordpress.org/support/users/designextreme/)
 * (@designextreme)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13202487)
 * [@bbrophy](https://wordpress.org/support/users/bbrophy/) I have a solution for
   the style sheet. I’ll outline the rough idea…
 * 1. In the plugin, disable the style sheet;
    2. In your theme’s “functions.php”
   file (you may need to create this), load the same style sheet (/wp-content/plugins/
   g-business-reviews-rating/wp/css/css.css) with the conditions you require (e.
   g. `is_page('reviews')` or similar).
 * Note that some functionality may be lost if the style sheet is disabled in the
   plugin (such as the SVG stars and their animation).
 * I found something that will handle the code at [Stack Exchange](https://wordpress.stackexchange.com/questions/39130/how-to-conditionally-enqueue-a-stylesheet-only-for-a-certain-pages).
 * I still don’t recommend loading the styles (or script) for just the page(s) where
   the short code exists.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Remove Plugin Action on Certain Pages’ is closed to new replies.

 * ![](https://ps.w.org/g-business-reviews-rating/assets/icon.svg?rev=2722684)
 * [Reviews and Rating – Google Reviews](https://wordpress.org/plugins/g-business-reviews-rating/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/g-business-reviews-rating/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/g-business-reviews-rating/)
 * [Active Topics](https://wordpress.org/support/plugin/g-business-reviews-rating/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/g-business-reviews-rating/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/g-business-reviews-rating/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 5 replies
 * 2 participants
 * Last reply from: [Noah Hearle](https://wordpress.org/support/users/designextreme/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/remove-plugin-action-on-certain-pages/#post-13202487)
 * Status: resolved