Filter enqueued styles and scripts


I am looking for a way to reorganize the scripts/styles queue in WP.

I am well aware of the fact altering the queue may have undesired effects, but in this case there are solid reasons for doing it and I will be keeping the situation under control.

I did not find a native WP filter to get that done.

I need to be able to iterate over the queued items before they are printed and reorganize them based on their type (CSS or Javascript). I still want to keep them differenciated between load in head and load in footer.

How may I achieve that? I thought about creating a function that prints the styles but caches the content via PHP Output Buffer and then parsing it with PHP Dom Document.

But… there has to be a less hacky way. Any suggestions?

Alvaro Franz 2 years 2022-01-18T15:15:46-05:00 0 Answers 0 views 0

Leave an answer