I AM LISTENING TO
|
WHAT I LIKE
  • English
  • German

Remove WordPress CSS / JS / Fonts website clutter

22. May 2015




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.

THE HUNT

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.

THE QUEUE

CSSJavaScript

CLEANUP

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.

DO YOU HAVE A NAME?

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.

IS THERE A PLUGIN FOR THAT?

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.”

BREAKING STUFF

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

… enjoy coding




Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments



Alexander

I am a full-stack developer. My expertise include:

  • Server, Network and Hosting Environments
  • Data Modeling / Import / Export
  • Business Logic
  • API Layer / Action layer / MVC
  • User Interfaces
  • User Experience
  • Understand what the customer and the business needs

 

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."

Previous Next