Title: Dequeue libraries when unneeded
Last modified: February 16, 2020

---

# Dequeue libraries when unneeded

 *  [Vincent Poirier](https://wordpress.org/support/users/magikweb/)
 * (@magikweb)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/dequeue-libraries-when-unneeded/)
 * Hi!
    We’d like to know how could load this plugin’s libraries ONLY on the pages
   that contain a Contact Form 7 (otherwise it’s useless and makes the page heavier).
 * Repost from: [https://wordpress.org/support/topic/potential-important-optimization/](https://wordpress.org/support/topic/potential-important-optimization/)
 * Thank you for any feedback!

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

 *  Thread Starter [Vincent Poirier](https://wordpress.org/support/users/magikweb/)
 * (@magikweb)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/dequeue-libraries-when-unneeded/#post-12757670)
 * Has anybody had any luck with this? Not necessarily with Contact Form 7, but 
   avoiding to load the whole Google reCaptcha in a static page that does not contain
   any form would be a decent upgrade. (Increase loading speed)
 *  [tahaferhani](https://wordpress.org/support/users/tahaferhani/)
 * (@tahaferhani)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/dequeue-libraries-when-unneeded/#post-13233102)
 * You can add this code to **functions.php** to remove it from the home page or
   you can add a condition to remove it from all page except the page where you 
   have Contact Form 7
 *     ```
       function conditionally_load_plugins() {
           // Remove from Home page
       	if(is_front_page()) {	
       		wp_dequeue_script('google-invisible-recaptcha');
       	}
       }
       add_action( 'wp_enqueue_scripts', 'conditionally_load_plugins' ); 
       ```
   

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

The topic ‘Dequeue libraries when unneeded’ is closed to new replies.

 * ![](https://ps.w.org/invisible-recaptcha/assets/icon-256x256.png?rev=1560060)
 * [Invisible reCaptcha for WordPress](https://wordpress.org/plugins/invisible-recaptcha/)
 * [Support Threads](https://wordpress.org/support/plugin/invisible-recaptcha/)
 * [Active Topics](https://wordpress.org/support/plugin/invisible-recaptcha/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/invisible-recaptcha/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/invisible-recaptcha/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [tahaferhani](https://wordpress.org/support/users/tahaferhani/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/dequeue-libraries-when-unneeded/#post-13233102)
 * Status: not resolved