Identifying the priority of style.css so I can make a small CSS file load last

When you properly enqueue a file, an instance of the wp_styles (more on this) class is created. The priority of actions is ignored. So it doesn’t matter if you write anything like

add_action ('wp_enqueue_scripts','function_adding_main_style',10);
add_action ('wp_enqueue_scripts','function_adding_small_style',11);

The reason is exactly the existence of the dependency system. WP first collects all enqueued style files and then checks them for dependencies. If A.css is enqueued before B.css but the former depends on the latter, they will be loaded accordingly. You can see this reordening happen in the all_deps method of the parent class.

To cut a long story short: you’re not supposed to mess with the priority of style files outside the dependency system that WP gives you. Your own solution is the best.

That said, you can always circumvent the enqueueing system and echo your file directly towards the end of the wp_head hook. Unelegant, but effective.

Leave a Comment