Subscribe via

WP Minify WordPress Plugin

I have previously reviewed the Minify PHP application and found that the only drawback it had for a WordPress user was that it was semi-tedious to integrate with WordPress. Because of that I would like to release the ‘WP Minify’ WordPress plugin that will integrate Minify into WordPress for you and help you improve your site load time.

Description

This plugin helps you easily integrate the Minify engine into your WordPress blog. Once enabled, this plugin will combine and compress JS and CSS files to improve page load time.

My site’s HTTP Requests before WP Minify (11 Javascript Requests @ 111KB) HTTP Requests Before WP Minify

My site’s HTTP Requests after WP Minify (1 Javascript Request @ 30KB) HTTP Requests After WP Minify

How Does it Work?

Upon page load, WP Minify intercepts scripts and style printing at the ‘wp_print_scripts’ and ‘wp_print_styles’ hook. WP Minify grabs these files in the proper order (minding dependencies) and passes that list to the Minify engine. The Minify engine then returns a consolidated, minified, and compressed script or style. WP Minify then references this compressed script or style in the WordPress header instead of each individual scripts/styles.

Features

  • Easily integrate Minify into your WordPress blog.
  • Minifies JavaScript, CSS, and HTML.
  • Debug tools to help you debug your issues.
  • Ability to include extra JS and CSS files for Minifying.
  • Ability to exclude certain JS and CSS files for Minifying.
  • Minified JS and CSS files can be placed wherever you want.
  • Support for to minifying external files via caching.
  • Ability to pass extra arguments to Minify engine.
  • Expire headers for minified JS and CSS files.
  • Detection and elimination of duplicate sources.
  • Plugin hooks!

Screenshots

Download

Installation

  1. Upload the plugin to your plugins folder: ‘wp-content/plugins/’
  2. Make sure ‘wp-content/plugins/wp-minify/cache’ is writeable by the web server. (try ‘chmod 777 wp-content/plugins/wp-minify/cache’)
  3. Activate the ‘WP Minify’ plugin from the Plugins admin panel.

Documentation

Where do I file bugs and ask for support?

Please post any support requests on the official WordPress support forum. Some kind soul may help you there. All support requests on this comment form will not be responded to.

Like the plugin?

If you are impressed with the plugin and would like to give back, here are some ways you can support this plugin:

Donations (Thank you!)

Credits

Code

This plugin uses the Minify engine currently being developed by Steve Clay and Ryan Grove.

Save and Share
StumbleUpon
Reddit

37 Responses to “WP Minify WordPress Plugin”

[go to last comment]
  1. Music

    Seriously….. I love that picture!! LOL. =D

  2. Ptah Dunbar

    Cool plugin, I was just looking into adding minify to my theme framework. I love your idea of catching all scripts and styles through wp's functions and processing them according. It makes for an easier integration and UX.

  3. Thaya Kareeson

    @Ptah Dunbar
    Thank you for your kind words! I will move this plugin out of beta soon. Stay glued to the RSS feed!

  4. Azizur Rahman

    I have been using the minify for a while.

    One suggestion that I'd make is that if you have an advanced options where by it would add required .htaccess re-wite rules for all CSS and JS files.

    for example:

    [code]
    RewriteRule ^(.*.(css|js))$ {path-to}/min/index.php?f=$1&debug=0 [L,NC]
    [/code]

    This will chatch all the css and js file and there is no need to specify all the files.

  5. Milan

    I don't know if you are aware of it, but there is one similar plugin (though I think that there is at least one more) so you should also check with it if there is something useful.

    Also, you should read about things for page performance introduced in 2.8, most notably inclusion of files in footer. First, second, third, fourth part, other reads. (you should check nightly builds)

    And about plugin itself: is there need that in name of minified files there are name of all scripts/styles that are included? For example, plugin mentioned above makes much better file names and I think that this is better for several reasons and most important for me is that there could be better cache control: if there are file names that are unique for every build of script/style, there could be cache that expires far in the future.

    Now they expire after only 15 minutes, which means that on every visit (not page view) there will be unnecessary conditional get (if-modified-since/if-none-match). If files have unique names, expire headers could be set for month or even a year.

    One more idea is to have option to include CSS files that are called by < link >. You know that theme's CSS are called this way. (idea from here, source code)

    And something very advanced: maybe in future releases there could be option that will allow webmasters to add path to files so that are loaded from other URL then example.com/wp-content/wp-minify/… (there is something like that for pictures in WordPress on miscellaneous options page) Why this? Read here about cookie free hostname.

    Even more advanced could be to add option so that files could be uploaded to Amazon S3 (like this plugin does for pictures) or to other server via FTP (I forgot if there is similar plugin for pictures). Why this? To move load from server where WordPress is hosted because even this minifiying, concreting and proper headers this server still needs to deliver this file to users and that makes additional load (we talk about trafficked websites) and use bandwidth of that server (maybe there is cheaper bandwidth for static files or webmaster wants to use CDN).

    Cheers!

    (p.s. posting comment with OpenID doesn't work here; I got 404 page; luckily I always save longer text, tough anyway I'm using Firefox which shows text in forms after clicking back button)

  6. Milan

    Hm, what happened with links? It seems that this IntenseDebate doesn't work so good, I again need to fill whole form again (Name, Email, URL)…

    Is it problem on your side or on their? If it is on their, I should send them this bug.

  7. Thaya Kareeson

    @Azizur Rahman
    Thank you for your great idea. I will probably add this in the next few versions. The only drawback I see with this is that you will not be able to get the performance increase from the reduced number of HTTP requests (see screenshots). That was the original point of the plugin (to be able to reduce HTTP requests for JS and CSS files by combining them into one single compressed file)

  8. Thaya Kareeson

    @Milan
    As far as I know right now, there is PHPSpeedy plugin that combines JS and CSS files into one optimized file to reduce the number of HTTP requests. I have tried PHPSpeedy and was quite unsatisfied with it (mainly because it doesn't work!).

    I've know that the core WordPress development team is working hard on this feature for 2.8. I just didn't think that they've gone that far. Based on your links, WP Minify already has one benefit over the 2.8 feature, "support for combining external Javascript/CSS files along with local ones". I believe the 2.8 feature will just queue these external scripts in the footer so the number of HTTP requests will not be reduced (plus you spend more time doing an externals DNS lookup on an external domain). What 2.8 has over WP Minify is that authors can now queue scripts in the footer. I will add an option to include these javascripts in the footer before the official release of this plugin (should be trivial to do).

    Your expire header point is good! I will definitely look into how to optimize this!

    The CSSStreamliner plugin idea is also awesome. I will definitely work that into WP Minify and I will probably get it to work with Javascript references too.

    The next suggestion for path specification is also valid. Thank you!

    Regarding Amazon S3, I was planning that in the future, but I'm not sure when I will be able to get to it. It will definitely be far away from now.

    Lastly, THANK YOU so much for the GREAT suggestions you have given me. They were very helpful. Please stay tuned to all of the updates I will be making to this plugin.

  9. Thaya Kareeson

    @Milan,
    It seems like the links worked fine for me. Any ideas?

  10. Milan

    About PHPSpeedy and WP 2.8: I don't use PHPSpeedy and I only tested it locally long time ago, but want to give you hint about it since you were maybe not aware of it; same applies for WP 2.8

    I believe the 2.8 feature will just queue these external scripts in the footer so the number of HTTP requests will not be reduced (plus you spend more time doing an externals DNS lookup on an external domain). What 2.8 has over WP Minify is that authors can now queue scripts in the footer.

    Page loads faster if JavaScript files are in footer (read Yahoo's rule "Put Scripts at the Bottom"). It's true that additional DNS lookup waste some time, but in some cases (when there are not many used hostnames) it can increase overall page load time.

    <blocquote>and I will probably get it to work with Javascript references too. </blockqoute>

    Just in documentation make notice that users use this carefully since many external Javascript files for statistics, ads, widgets etc. could be used on page so in some cases they shouldn't be in local javascript file (e.g. Google Analytics or AdSense javascript files are probably already cached by browser because many websites use them).

    <blockqoute>Lastly, THANK YOU so much for the GREAT suggestions you have given me. They were very helpful. Please stay tuned to all of the updates I will be making to this plugin.</blockqoute>

    No problem, I know how hard is to optimize page for better performance and it's better to make tool that will do majority things for you, meaning you save time later. And since this is open source software, I have some kind of obligation to help to it, since I use many open source software.

  11. Milan

    It is probably problem with AJAX. Same thing happened with comment below but after page refreshing it is shown as it is indented.

  12. Tadd

    I'm getting an error with this plug in:

    Fatal error: Call to undefined function: substr_compare() in /homepages/7/d179418042/htdocs/v3/wp-content/plugins/wp-minify/wp-minify.php on line 263

    All I did was install.

    Using WP 2.7.1

    And I just realized that PHP5 isn't enabled natively on my 1and1 server .. sadly, enabling this in htaccess just kills my site, but yeah .. will have to figure something else out here.

    The plug looks really promising and I hope I can figure out how to use it eventually!

  13. jasondrohn

    This really is great work.. SuperCache is a great plugin – but sometimes it can't handle the java loading on pages very well…

    JD

  14. wp123

    This is just what I was looking for. Thank you very much. Looking forward to see full version soon. :)

  15. Thaya Kareeson

    This is most likely Intense Debate's issue. I'm really thinking about switching back to regular WordPress comments.

  16. Thaya Kareeson

    Ah.. I wasn't aware that substr_compre() is only for PHP5. I will fix it before the official release. Thanks Tadd!

  17. Thaya Kareeson

    Thank you! Please stay tuned to the RSS feed. It will be out very soon. Within a week or so.

  18. Thaya Kareeson

    @jasondrohn
    Thank you very much for your kind words!

  19. Jacob Share

    Currently, I minify files before I push them out to my site so this sounds like a timesaver. Plus, if I can use it to dynamically minify and cache remote js files (like Google Analytics'), I will donate $ once I can get it to work.

    Testing it out on my WPMU 2.7 test environment, I'm seeing some strange behavior. Using Firebug to see which js files are being called, I can see that when WP-Minify is activated in its default configuration (no custom additions in the admin panel), the minified js file is being generated but there's also a separate call for '…/wp-includes/js/prototype.js?…'. Before I activated WP-Minify, that tested page didn't make a call to prototype.js, but it was making a call to jquery (which was caught by WP-Minify later). Since prototype is fairly large, having WP-Minify activated actually increases the page weight in this example.

    Any idea where prototype is coming from here?

  20. Thaya Kareeson

    Hi Jacob. Thanks for testing this. I thought I have fixed this bug in version 0.1b3, can you check which version you have?

  21. Jacob Share

    Doh! The readme says 0.1b3 too.

  22. Thaya Kareeson

    Hmm… let me look into getting a WPMU installation up to try to reproduce this bug. Thanks Jacob!

  23. Darren

    Thaya,

    Thanks for putting together this great plugin. I've been using minify for a while now with wordpress and it's great to see a plugin implementation of the library. I've got a couple suggestions based on things I've run into with my particular setup.

    This might be a limitation of wp_enque_styles, but is there any way to implement support for conditional comments? I usually have at least one stylesheet in a conditional comment for IE after my main stylesheets.

    I was also wondering if it would be possible to implement a "don't gzip" option. My host tends to gzip things on the fly which sometimes causes problems with scripts that also gzip things. It would be nice to have the option to minify and concatenate and then let the server do the gzipping part.

    Keep up the good work! Great to see you bringing this great library to WordPress.

  24. Thaya Kareeson

    I'll see what I can do to work the IE switch into the code (not sure yet though).

    About the "don't gzip" option, I will have to look into the Minify documentation to see if it's possible.

    Thanks for the suggestions! Stay tuned to the RSS feed to see what happens within this week!

  25. John

    Installed plugin on this site, http://www.cpajohn.com and it caused the ">" to disappear in the PixoPoint Multi-level Navigation Plugin that indicates there is a dropdown menu with subpages.

    The plugin mentions this feature uses jquery.

  26. Thaya Kareeson

    Released 0.1.1
    – Fixed array_slice() warning in the admin dashboard.
    – Fixed version check to not break page when $wp_version is empty.

  27. Avinash

    Can i use it with WP-Super cache and will it produce better loading than WP-Super cache.??

  28. Darren

    WPMinify seems to break lightbox scripts…

  29. thaya

    Yup, as specified in the plugin description.

  30. thaya

    Thanks for reporting this Darren. I will look into this for the next version.

  31. Andy

    How can i get wp-geo working with this? Great work, thanks in advance!

  32. Thaya Kareeson

    Lock up this comment thread so people can post support questions in the support forum.

  33. FreewareMatter

    This way does not work with JS files. When I use this code, it redirects my home page to {mydomain.com}/min/index.php?f=index.js. I don't know why :(. Can you help me to fix this.

    Now I use only this for CSS files:

    RewriteRule (.*.css)$ {path-to}/min/index.php?f=$1&debug=0 [L,NC]

  34. V.C

    I used your plugin for a few days.
    It really worked but one problem: all of my files was compressed and it made my site look very simple. So I decided remove it.

  35. Milan

    What does it mean "it made site look very simple"?

  36. Thaya Kareeson

    I think he just means that one of the CSS files were not minified properly. The best solution for this is to just exclude the CSS from minify. Instructions are on the troubleshooting document.

  37. Hi, I tried the plugin, but it gives me the following error Error: Could not fetch http://xslt.alexa.com/site_stats/js/t/b?url=http:… for caching. You might need to exclude this file in WP Minify options

    It's talking about a script, alexa, that I have running in the side column. I tried a couple of things but they don't work.

    The plugin also stuffs up the TwitterRemote plugin.

[go to first comment]