Thread Starter
ztof
(@ztof)
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.
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
(@ztof)
Hi dataroots, thanks.
Indeed, it’s better for maintenance and plugin updates to use your solution.
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.