Including and Excluding FooBox Asset Loading

FooBox Documentation

Including and Excluding FooBox Asset Loading

As you already know, FooBox adds lightbox functionality to your website. The nature of WordPress shortcodes and plugins limits the ability to know when images or videos will be on a specific page, so FooBox assets are loaded on all pages on your website.

FooBox Assets Are Loaded On All Pages

By default, the Javascript and CSS files that FooBox uses are loaded on all pages and posts. You can however,  choose to disable FooBox assets from loading on certain pages or posts. To do this, edit your page or post, and locate the FooBox Javascript & CSS metabox. If you’re using the block editor, it is located in the document settings of the page. Simply check the checkbox and update your page. No more FooBox assets will be loaded!

Exclude FooBox

Having the assets loaded on all pages makes sense for graphic intensive websites, but it does not make sense for smaller sites that only make use of FooBox on 1 or 2 pages.

Can I Disable Assets Loading?

Yes! Navigate to the FooBox Settings -> Advanced tab. Check the setting  Exclude FooBox Assets:

Exclude FooBox Assets

Now, all pages and posts will not load the FooBox assets.

Opt-In to Load FooBox Assets

With the Exclude FooBox Assets setting checked, you can now selectively include the assets only on the pages you want to use FooBox. Edit the page in question, and find the  FooBox Javascript & CSS metabox. You will now notice it has the option to INCLUDE, rather than EXCLUDE as it had before. Check the checkbox to include FooBox Assets:

Include FooBox