Home » Development » Remove WordPress CSS / JS / Fonts website clutter
WordPress is fun, but many of my clients take the plugin fun to new levels :)
Depending on how well plugins / shortcodes have been integrated, linked JavaScript & CSS files can clutter up your pages really fast.
The problem is that many plugins do not load external files on demand. Same applies for WebFonts that have been added to the system.
Its no fun hunting down all those resources and slim down pages manually, but sometimes there is no way around it.
In WordPress CSS & JavaScript files are enqueued by plugins / themes.
CSS / JavaScript
To remove files from pages you need to unregister (CSS / JavaScript) those files using their specific handle. This also allows you to replace a specific file with your own version.
The big problem is finding the names of the enqueued files, their handles. They are often hidden deep in the plugins. But if they are registered somewhere, you should be able to find them somewhere :)
Add this to your functions.php and you will get a nice overview of all the styles and their handles registered. You can do the same for the registered scripts.
This will get you an overview of all the registered files. Now its only a matter of doing the unregister operation with some simple WordPress conditional logic.
Yes there is and it is called “Asset Queue Manager” …
“This tool allows you to monitor, dequeue and requeue scripts and styles that are enqueued on your site. It is designed for frontend performance engineers who want to view and manage all assets enqueued on any page and control the minification and concatenation themselves.”
Messing with styles can be ugly, but often wont break things completely. Messing with JavaScript includes can cripple a setup badly. So you should be really sure which scripts / styles can be deactivated on specific pages. Please do not experiment on a live website … I warned you ! :)
Alexander Gräf
Portfolio
Book Me
Get in touch
Live Chat
I am a full-stack developer. My expertise include:
I love programming, design and know my way around server architecture as well. I would never feel complete, with one of these missing.
I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.
Apart from that, I am a peace loving guy who tries to have people around him that think the same. I truly believe in the principle: “If you help someone, someone will help you, when you need it."