Remove an Enqueued Stylesheet in WordPress

November 30, 2015

When working on a pre-existing version of a site, you may need to check if a style is already loaded. This, in and of itself, is not that difficult, but if it’s using an older version of a dependency, then it can get a little more complicated.

For example, let’s say that you’re building a plugin for an existing site. The existing site uses something like Font Awesome, but it’s using an older version.

The requirements call for some updated icons that aren’t available in the existing version. Furthermore, the version of Font Awesome maybe be the minified version or not so we need to check for that.

Remove Enqueued Stylesheet

One of the challenges that comes with doing this in the context of a plugin is that you don’t know when the other styles are enqueued. As such, we have to make sure that we properly prioritize the hook.

Just Getting Started with WordPress?

I write a lot about WordPress development but if you're just getting started, I recommend checking out WPBeginner. They have free training videos, glossary, and more.

WPSessions hosts some of the best WordPress training you’ll find anywhere from many well-known speakers.

If there’s something you’d like to learn, and it’s not already covered here, it’s probably been covered at WPSessions. If you use the special link below you can watch your first session for free and get a steep discount on the full-access VIP membership.