Title: Load javascript code only when needed
Last modified: September 1, 2016

---

# Load javascript code only when needed

 *  [folettiwebdesigner](https://wordpress.org/support/users/folettiwebdesigner/)
 * (@folettiwebdesigner)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-code-only-when-needed/)
 * This plugin is really nice, but there are two ‘issues’ that still prevents me
   from using it:
 * – It is loaded on every page, even ones without galleries. Usually, plugins like
   this are loaded only when needed.
    – It loads 5 javascripts files, so it adds
   5 http requests, that are really too many in my opinion. Couldn’t they be merged
   into one file only?
 * Thank you in advance, keep up the great job!
 * [https://wordpress.org/plugins/photoswipe-masonry/](https://wordpress.org/plugins/photoswipe-masonry/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [THRIVE – Web Design Gold Coast](https://wordpress.org/support/users/deanoakley/)
 * (@deanoakley)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-code-only-when-needed/#post-7488551)
 * Hi. You can use caching plugins to compress all your scripts into one file. W3TC
   has worked well for me.
 * Also see [http://thriveweb.com.au/the-lab/photoswipe/](http://thriveweb.com.au/the-lab/photoswipe/)
   
   Conditionally remove header scripts and styles from a page.
 * I hope that helps!

Viewing 1 replies (of 1 total)

The topic ‘Load javascript code only when needed’ is closed to new replies.

 * ![](https://ps.w.org/photoswipe-masonry/assets/icon-128x128.png?rev=3464802)
 * [Photoswipe Masonry Gallery](https://wordpress.org/plugins/photoswipe-masonry/)
 * [Support Threads](https://wordpress.org/support/plugin/photoswipe-masonry/)
 * [Active Topics](https://wordpress.org/support/plugin/photoswipe-masonry/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/photoswipe-masonry/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/photoswipe-masonry/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [THRIVE – Web Design Gold Coast](https://wordpress.org/support/users/deanoakley/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/load-javascript-code-only-when-needed/#post-7488551)
 * Status: not resolved