Title: Nice plugin
Last modified: August 10, 2022

---

# Nice plugin

 *  [bro007](https://wordpress.org/support/users/bro007/)
 * (@bro007)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/nice-plugin-4696/)
 * Good plugin, what you need! The only thing that could be corrected in it: so 
   that it displays its styles (.css) and scripts (.js) only in posts, and not everywhere
   🙂 Well, or so that you can choose where to turn it on … It would be just great!

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

 *  Plugin Author [Johannes Kinast](https://wordpress.org/support/users/goaroundagain/)
 * (@goaroundagain)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15906998)
 * Hi [@bro007](https://wordpress.org/support/users/bro007/),
 * The Plugin tries to detect, if there is a supported Gallery/Image Block present
   on the page and only loads the style & script for performance reason than. If
   you just have one gallery on your website, your users only have to download the
   script & style and execute it if they are really necessary.
 * If you want to change this behavior on your site, just add this snippet to your`
   functions.php`:
    `add_filter( 'baguettebox_enqueue_assets', '__return_true' );`
 *  Thread Starter [bro007](https://wordpress.org/support/users/bro007/)
 * (@bro007)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15911543)
 * When adding: add_filter( ‘baguettebox_enqueue_assets’, ‘__return_true’ ); – everything
   remains as it is (all scripts and plugin styles are also displayed on all pages,
   that is, nothing changes). I need them to be displayed only in posts (I have 
   galleries in posts).
 *  Thread Starter [bro007](https://wordpress.org/support/users/bro007/)
 * (@bro007)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15911578)
 * I wrote about the fact that it would be nice if the plugin added scripts and 
   styles, only where there are galleries. I have them in posts, and the plugin 
   adds them more: in archives, on panigation pages. This is what I meant … (although
   this is not critical).
 *  Plugin Author [Johannes Kinast](https://wordpress.org/support/users/goaroundagain/)
 * (@goaroundagain)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15916330)
 * [@bro007](https://wordpress.org/support/users/bro007/) I am sorry, I misunderstand
   your review. In fact, the plugin tries to detect if there is a supported gallery/
   image Block on the page and only loads the script & styles if necessary. There
   can be some false positive, e.g. on an archive page where there is only the excerpt
   displayed, but there is an image/gallery block in a post. I think this is better
   than false negative cases.
 * With the `baguettebox_enqueue_assets` filter you can control where the script&
   styles should be loaded: [https://wordpress.org/plugins/gallery-block-lightbox/#how%20to%20enqueue%20the%20necessary%20assets%20%28script%20%26%20style%29%20for%20blocks%20outside%20of%20posts%20or%20for%20block%20types%20that%20are%20not%20supported%20by%20default%3F](https://wordpress.org/plugins/gallery-block-lightbox/#how%20to%20enqueue%20the%20necessary%20assets%20%28script%20%26%20style%29%20for%20blocks%20outside%20of%20posts%20or%20for%20block%20types%20that%20are%20not%20supported%20by%20default%3F)
 * This should apply your desired behavior: (not tested)
    `add_filter( ‘baguettebox_enqueue_assets’,
   function() { return is_single(); } );`
 *  Thread Starter [bro007](https://wordpress.org/support/users/bro007/)
 * (@bro007)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15916514)
 * Thank you for your attention 🙂 Yesterday I found a function with which I achieved
   the desired result, and also removed other styles on my site with its help:
 * function disable_scripts_styles(){
    if ( !is_single() ) { wp_dequeue_style( ‘
   baguettebox-css’ ); wp_dequeue_script( ‘baguettebox’ ); } } add_action( ‘wp_enqueue_scripts’,‘
   disable_scripts_styles’, 99 );
 * Might be useful for someone… Thank you, your lightbox plugin is the best!
 *  Plugin Author [Johannes Kinast](https://wordpress.org/support/users/goaroundagain/)
 * (@goaroundagain)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15916543)
 * [@bro007](https://wordpress.org/support/users/bro007/) this works, too.

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

The topic ‘Nice plugin’ is closed to new replies.

 * ![](https://ps.w.org/gallery-block-lightbox/assets/icon.svg?rev=2788519)
 * [Lightbox for Gallery & Image Block](https://wordpress.org/plugins/gallery-block-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gallery-block-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gallery-block-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/gallery-block-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gallery-block-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gallery-block-lightbox/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Johannes Kinast](https://wordpress.org/support/users/goaroundagain/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/nice-plugin-4696/#post-15916543)