wpmetabox / meta-box

The best plugin for WordPress custom fields and custom meta boxes
https://metabox.io
1.19k stars 423 forks source link

Prepare css to be inlined #1555

Closed ictbeheer closed 9 months ago

ictbeheer commented 9 months ago

By adding the path attribute to registered/enqueued style it allows WordPress to print some styles inline: https://developer.wordpress.org/reference/functions/wp_maybe_inline_styles/

This is beneficial for front-end forms as the Meta Box field css files are mostly very small; inlining them reduces the number of http requests.

I added the attribute to all styles for constencies sake; some of them will probably never be inline unless someone uses the 'styles_inline_size_limit' filter to increase to maximum size of inlined styles.

rilwis commented 9 months ago

That's a nice improvements! Thanks a lot for your help.

I'm thinking of writing a helper function to enqueue CSS file, so we don't have to repeat the code. Probably another PR.