Title: Optimized Code
Last modified: April 1, 2022

---

# Optimized Code

 *  Resolved [palmtek](https://wordpress.org/support/users/palmtek/)
 * (@palmtek)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/optimized-code/)
 * Howdy,
    Does your plugin load JS and CSS all the time or only on pages/posts 
   where it is used? Does it load only the code for blocks used? Thank you

Viewing 1 replies (of 1 total)

 *  Plugin Author [WebMan Design | Oliver Juhas](https://wordpress.org/support/users/webmandesign/)
 * (@webmandesign)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/optimized-code/#post-15518808)
 * Hi [@palmtek](https://wordpress.org/support/users/palmtek/),
 * The plugin hooks onto WordPress native functionality to load the CSS code. All
   the CSS styles are registered as inline styles via [`register_block_style()` function](https://developer.wordpress.org/reference/functions/register_block_style/).
   These are being added to HTML head (by default) by WordPress itself whenever 
   it enqueues `wp-block-library` stylesheet (which seems to be all the time?).
 * For themes that don’t support separate block assets loading (check [`wp_should_load_separate_core_block_assets()` function](https://developer.wordpress.org/reference/functions/wp_should_load_separate_core_block_assets/)),
   such as Twenty Twenty-One theme, this means all plugin’s CSS styles are being
   inlined when `wp-block-library` stylesheet is enqueued by WordPress. This is 
   roughly 23 KB of [minified CSS code](https://github.com/webmandesign/additional-block-styles/tree/main/assets/css).
 * On the other hand, when the theme supports separate block assets loading, such
   as Twenty Twenty-Two theme, only the CSS code for specific block styles used 
   in the page/post content are being inlined. Plus a global CSS is always being
   inlined in this case, which is 420 bytes of minified CSS code on front-end.
 * No JavaScript is being loaded by the plugin.
 * Best regards,
 * Oliver

Viewing 1 replies (of 1 total)

The topic ‘Optimized Code’ is closed to new replies.

 * ![](https://ps.w.org/additional-block-styles/assets/icon.svg?rev=2701784)
 * [Abs - Additional block styles](https://wordpress.org/plugins/additional-block-styles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/additional-block-styles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/additional-block-styles/)
 * [Active Topics](https://wordpress.org/support/plugin/additional-block-styles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/additional-block-styles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/additional-block-styles/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WebMan Design | Oliver Juhas](https://wordpress.org/support/users/webmandesign/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/optimized-code/#post-15518808)
 * Status: resolved