Skip to content

Deregistering Unwanted Styles and Scripts in WordPress

In this post, we’ll be discussing how to deregister unwanted styles and scripts in WordPress using a simple code snippet. Deregistering unnecessary styles and scripts can help to improve page load time and performance, especially on sites with a lot of third-party plugins and themes.

The code snippet uses the wp_enqueue_scripts action and the wp_dequeue_style and wp_dequeue_script functions to deregister specific styles and scripts.

The custom_deregister_styles_and_scripts function is attached to the wp_enqueue_scripts action with a priority of 11. Inside the function, it uses the wp_dequeue_style function to dequeue the wp-block-library style, and the wp_dequeue_script to dequeue the wc-cart-fragments script.

Summary

By adding this code snippet to your functions.php file, you can dequeue styles and scripts. Remember to test it before going live and make sure you have the proper backup of your website.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *