Title: Javascript and CSS  loaded on every pages?
Last modified: August 22, 2016

---

# Javascript and CSS loaded on every pages?

 *  [ztof](https://wordpress.org/support/users/ztof/)
 * (@ztof)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/)
 * I’m using FooBox with Foo Gallery, and I’m just wondering why the javascript 
   part (foobox.free.min.js file and inline scripts) and css part **are loaded on
   every single pages of the website**, when I’ve got just one gallery on one page.
 * It’s a bit of useless overload…
 * Is there a way to get rid of that behaviour, either by configuring something 
   in the settings or by doing code modification on the plugin?
 * Thanks in advance for replies.
 * [https://wordpress.org/plugins/foobox-image-lightbox/](https://wordpress.org/plugins/foobox-image-lightbox/)

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

 *  Thread Starter [ztof](https://wordpress.org/support/users/ztof/)
 * (@ztof)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/#post-5907893)
 * Answering myself:
 * I had to change directly in plugin’s code (not cool for maintenance) in file:
   /
   wp-content/plugins/foobox-image-lightbox/foobox-free.php at line 64 and comment
   those lines (to get it stops loading its stuff on every page and forcing jquery
   to load in the headers):
 *     ```
       } else {
   
       				// Render JS to the front-end pages
       			//	add_action('wp_enqueue_scripts', array($this, 'frontend_print_scripts'), 20);
       			//	add_action('foobox-free_inline_scripts', array($this, 'inline_dynamic_js'));
   
       				// Render CSS to the front-end pages
       			//	add_action('wp_enqueue_scripts', array($this, 'frontend_print_styles'));
       			}
       ```
   
 * All this stuff will managed and loaded wisely by a conditionnal function (at 
   FooGallery level), only when a gallery is displayed, which is better for site
   performance and optimization.
 *  [dataroots](https://wordpress.org/support/users/dataroots/)
 * (@dataroots)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/#post-5908119)
 * Hi ztof,
 * It’s been a while since you posted your question, but I just came across it today.
   To exclude the FooBox javascript and css files from the homepage, you can include
   this code in your functions.php file:
 * function my_deregister_styles() {
    if ( is_front_page() ) { wp_deregister_style(‘
   foobox-free-min’ ); wp_deregister_script( ‘foobox-free-min’ ); } }
 * Hope this helps!
 *  Thread Starter [ztof](https://wordpress.org/support/users/ztof/)
 * (@ztof)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/#post-5908120)
 * Hi dataroots, thanks.
    Indeed, it’s better for maintenance and plugin updates
   to use your solution.
 *  [Jarod Thornton](https://wordpress.org/support/users/jarmerson/)
 * (@jarmerson)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/#post-5908139)
 * Just installed this plugin on WPMU and testing it. So far I am very impressed
   and hopeful development continues! Thanks for a great lightbox plugin!!!
 * I would be interested to find a solution for this that is more efficient i.e.**
   scripts / styles only queued when photos are using lightbox**. So if a page /
   post **does not have a gallery etc** that uses foobox these **resources are not
   queued**.

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

The topic ‘Javascript and CSS loaded on every pages?’ is closed to new replies.

 * ![](https://ps.w.org/foobox-image-lightbox/assets/icon-256x256.gif?rev=2667030)
 * [Lightbox & Modal Popup WordPress Plugin - FooBox](https://wordpress.org/plugins/foobox-image-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/foobox-image-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/foobox-image-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/foobox-image-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/foobox-image-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/foobox-image-lightbox/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Jarod Thornton](https://wordpress.org/support/users/jarmerson/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-and-css-loaded-on-every-pages/#post-5908139)
 * Status: not resolved