Creating Small Components in a Theme and Loading CSS for Each Part

I routinely build reusable components for WordPress plugins and then run a series of conditional checks on whether or not to load the components, so it’s common practice for me and I’ve learned it over the years by looking at other plugins, so I’d say yes.

As for the CSS I’ll register all of the CSS files but not actually enqueue them until they’re needed.

wp_register_style( 'style-handle' ) is what I use to register them all in an enqueueing component, but then, within the component that requires one of the specialized/specific stylesheets, I run a conditional check to make sure it hasn’t already been loaded, in case a component fires twice on a page, I only want the CSS loading once:

if( !wp_style_is( 'style-handle' ) ) :
    wp_enqueue_style( 'style-handle' );
endif;

This seems to work for me, keep things nice and origanized and only loading what’s needed at any given time.

You can do the exact same with scripts using wp_script_is().

deneme bonusu veren sitelerbahis siteleripulibet girişdeneme bonusutürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişholiganbetholiganbet girişholiganbet güncel giriş