WordPress Plugin – Allows to selectively dequeue scripts/styles on each post

The plugin allows to dequeue or remove a script/style on a per post basis. It helps to improve performance of the site and you can make sure that atleast your important pages are optimised.

Download the plugin from WordPress Plugins Repository

The plugin is very simple. All you need to do is to edit a post which you wish to optimise and on the WPI Enqueue Manager meta box add the handles of the scripts or styles in bar (|) separated format to dequeue it from that post.

Detailed instructions on how to use this plugin

  1. Install and activate the plugin
  2. Upon activation, the plugin will show all the handles related to each enqueued styles/scripts on the source code of every page. Please see below screenshot
    script and style handles
  3. Just edit the post and add the scripts/styles in relevant boxes in bar (|) separated format to remove it from that post. Please see below screenshot

Enqueue Manager

 

How to selectively dequeue a script on individual post

Lot of plugins. Not sure what to do??

All of a sudden you may realise that you already have quite a lot of plugins on your website and probably some of those plugins are slowing your site down. That’s the point of time you may decide to review your plugins but at that point it is very difficult to imagine the impact of deactivating a certain plugin.

Here is a simple trick we can use to review our plugins and make sure atleast our important pages do not break.

Idea

The idea is to try and dequeue or remove a script on a page by page basis or post by post basic. Using this approach we are not deactivating the plugin on the entire site but we are just deactivating or removing it on just a single post or page. This way we can study the impact of removing the plugin on our most important pages/posts just so that we are sure it won’t break our site and we feel more comfortable to deactivate the plugin entirely on our site.

So how do we achieve this

Step 1: Print all the script handles used on a page/post

Step 2: Create a custom field

Create a custom field named wpi_selective_scripts_dequeue on our post/page and add bar separated (|) handles of the scripts which you wish to remove from the page (referring to list generated in step 1)

Step 3: Dequeue the script for that page/post