3

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?

2

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. :)

  • I'm aware of that. I'm trying to figure out what sets the order when there are no listed dependencies. – Sirmontegu Apr 12 '17 at 17:44
  • 1
    It's like priorities I guess. If two enqueues have the same deps, then it's like having the same priority. It doesn't matter which one loads first – Prasun Jajodia Apr 12 '17 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.