Bricks loads Woo CSS & JS files on Non-WooCommerce pages

Bricks Version: 1.3.7
Browser: Chrome 9x
OS: macOS / Windows

Not sure if this a bug, but it goes against the Bricks principle of loading only necessary CSS and JS.

The following code is loaded on every page, but I think this code should only be loaded on pages with Bricks Woocommerce builder code and modules on the page. Not every page on the site. Of course getting rid of this unneeded code can be achieved by using an assets manger plugin, but really that should not be needed with Bricks.

/wp-content/themes/bricks/assets/css/integrations/woocommerce.min.css?ver=1643230226
/wp-content/themes/bricks/assets/js/integrations/woocommerce.min.js?ver=1643245966

1 Like

Hi @bricksandmortar,

thanks so much for your report! You are completely right, they shouldn’t be there :weary:
We’re going to ix this in the next version.

Best regards,
timmse

2 Likes

Hmm… Those assets might be needed if using WooCommerce elements outside of Woo pages. Don’t remove them by default. I would opt for a assets manager plugin / WP functions in this scenario instead.

Hi!
They should be loaded if a woo element is used on the homepage, for example. But if the homepage doesn’t contain a woo element, they are unnecessary.

To be clear, I am seeing this code on pages with NO woo elements!

As @madedo pointed out the Bricks woocommerce.min.css & woocommerce.min.js contain default Woo styling & scripts that are needed on non-Bricks pages. Such as the shop page, checkout pages, account pages, order pages, product archive pages, etc.

They might also be needed on custom pages that contain certain Woo render functions, which are impossible to predict.

For those reasons we decided to load these two files. Loading them conditionally by default can easily result in broken styles/functionality due to missing CSS & JS. Which is something you really don’t want in an online shop. It’s probably not worth the few Kbs you’d save by not loading them on a few pages. Which at some point throughout the purchasing path on the website will be requested anyway.

Also, those assets are only requested/loaded once, and are then browser-cached for subsequent requests.

For those that would like to further apply conditional assets loading using an asset manager is probably the best solution.

1 Like