New WordPress Plugin – Script-Style-Killer

WordPress loads many scripts and styles, (jQuery core and various-jQuery-plugins are few of the major ones)
in-case you don’t really need them, I’ve wrote a plugin that will “kill” (remove from the HTML, in a very unforgiving way..),
this without the need to dig into the WordPress-API itself.

Track the added script and styles added to your page, by copy&pasting the following code into your template (use any FTP-client for that), just don’t forget to remove it after you’ll be done with-it.

<!-- <?php
  global $wp_styles;
  global $wp_scripts;

  var_dump($wp_styles);
  var_dump($wp_scripts);
?> --> 

icompile.eladkarako.com_page_scripts_and_styles_example1

“Killing” scripts and styles of your page is done by commenting them out of the HTML,
meaning:
<script type="text/javascript" async="async" src=""http://icompile.eladkarako.com/wp-content/plugins/wp-cleanfix/wpdk/assets/js/timepicker/jquery.timepicker.js?ver=1.1.0"></script>
will transform into
<!-- SCRIPT-KILLER:["jquery"]/REMOVED:["http://icompile.eladkarako.com/wp-content/plugins/wp-cleanfix/wpdk/assets/js/timepicker/jquery.timepicker.js?ver=1.1.0"] -->

icompile.eladkarako.com_page_scripts_and_styles_example_action

naturally *one* should check the console for errors such as could not find '$' (or .. jQuery'),
but if your wordpress-plugins do not use jQuery, it should be rather safe..

those are the keywords that will trigger the script -or- style removing (with no particular order, ..and it is not case-sensitive)

  • jquery
  • backbone
  • prototype
  • scriptaculous
  • thickbox
  • embed
  • a11
  • i18n
  • cleanfix

using Google PageSpeed (by Apache’s plugin “ModPageSpeed”) or this cool minifier plugin for WordPress can remove the comments and make the entire textual content quite small indeed..

have fun!

Leave a Reply