Typically when I add stylesheets I use wp_enqueue_style multiple times within a single function, then call that function once with wp_enqueue_scripts. There doesn’t seem to be any logic to the order those sheets loaded. They don’t load in the order they are listed, or any other reasonable order I can find.

I understand how to use priority on actions, but that requires a unique function for use with each hook. I’m currently using that to overcome this issue, but I’m curious. Is there something that determines how styles are loaded when several are enqueued within the same function? And if not why?

1 Answer
1

In the codex for wp_enqueue_style, there is an argument for dependencies.

So if I enqueue style A with deps B and C, A will be loaded after B and C. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *