Title: Loading JS when not needed
Last modified: August 22, 2016

---

# Loading JS when not needed

 *  [Squazz](https://wordpress.org/support/users/squazz/)
 * (@squazz)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-when-not-needed-3/)
 * I have just run a couple of speed tests om my site, and it seems that JS files
   for Contact Form 7 are fetched even when they aren’t needed.
 * We are talking about 2 requests with a combined weight at about 9.3Kb:
    contact-
   form-7/includes/js/jquery.form.min.js contact-form-7/includes/js/scripts.js
 * Example page with the problem: [https://www.musalaha.org/about-us/who-we-are/](https://www.musalaha.org/about-us/who-we-are/)
 * Sidenote: Can it be true that Contact Form 7 aren’t serving minimized versions
   of scripts.js?
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

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

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-when-not-needed-3/#post-5567489)
 * [Loading JavaScript and Stylesheet Only When it is Necessary](http://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/)
 *  Thread Starter [Squazz](https://wordpress.org/support/users/squazz/)
 * (@squazz)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-when-not-needed-3/#post-5567584)
 * That’s a fine solution, but not really all that flexible. I would have to update
   that code for each page (that does not use this template) containing a Contact
   Form.
 * Why not do something like [this solution from scribu](http://scribu.net/wordpress/optimal-script-loading.html)?

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

The topic ‘Loading JS when not needed’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Squazz](https://wordpress.org/support/users/squazz/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-when-not-needed-3/#post-5567584)
 * Status: not resolved