Blaine Freelance

A problem I had with wp_enqueue_style not appearing to load any stylesheets

October 14, 2017

So I had a problem with wp_enqueue_style seemingly not loading any stylesheets! Arg! I spent 3 hours trying to figure this one out.

When I would look at the page source of the site I was working on, I couldn’t find the stylesheet I had enqueued with wp_enqueue_style… anywhere. After three hours of taking shots in the dark trying to fix this, I put body { background-color: black; } in my stylesheet. To my astonishment, the page turned black. My styles were being recognized by the browser. Yet I saw no reference to the CSS file in the page source anywhere. Despite this being a major WTF, it told me something. My styles were making it to the page. I was able to turn the page black with CSS. I looked through the page source… again… and found my styles in an inline script tag. Not where I was expecting them to be.

How did my styles go from being in their own file to being in an inline script tag? A plugin called autoptimize.

*womp womp trombone*