33 Comments

  1. Topher

    One drawback is that is doesn’t handle stylesheets included with @import. If you HAVE stylesheets like that, you should switch them to use wp_enqueue_style, example here: http://codex.wordpress.org/Function_Reference/wp_enqueue_style#Using_a_Hook

    That loads them faster anyway.

    Report

  2. Caspar Hübinger

    I often wonder whether or not it makes sense when themes minify their scripts and stylesheets by default. Generally, it seems good practice (as long as an unminified version is provided alongside), but once you have any other plugin enqueuing a script or stylesheet and it’s not minified, there goes your page speed metric — not to mention minification obviously doesn’t save you any HTTP requests. In short, thanks for the post, I might try this.

    Report

  3. Rob Skidmore

    Looks pretty nifty. The fact that its tackling quite a bit of delicate work and it hasn’t been updated in close to a year makes me a little nervous though.

    Guess I’ll have to try it out.

    Report

  4. Michael Novotny

    The only thing I am curious about is the decision to store the concatenated / minified source in the wp_options table.

    I wonder what the speed is on that vs. actually writing to files where a CDN can actually see them and cache them. Anyone have any insight there?

    Report

    • Ryan Hellyer

      You can use a CDN to cache a dynamically generated file too, so that issue is somewhat moot.

      Report

      • Michael Novotny

        Perhaps I didn’t word my question clearly… Let me try again.

        Yes, I do know and agree that CDNs can cache both static and dynamically generated files equally.

        What I am questioning (not calling out, just pondering) is Dependency Minification’s decision to store the minified and concatenated output in the get_options table where a CDN cannot cache it.

        I am simply wondering how much of a performance hit constantly retrieving the option from the database will be vs. having the plugin kick out a dynamically generated file and letting a CDN do it’s job and take that hit.

        Report

  5. erikvlie

    Has anyone seen the plug-in only to be compatible with WP up to 3.8.3? Or is that an unimportant detail?

    Report

  6. Ryan Hellyer

    I haven’t found any concatenation plugins which didn’t bug out in many different situations or which used nasty hacks to make them work. Hopefully this one works better.

    I do prefer the Minit plugin’s approach to cache refreshing though. It does a modified date check on the files, then MD5’s it and uses that for the file name. That way whenever an enqueued file is updated, the cache is refreshed automatically. It would be much more convenient than having to wait for a Cron job to fire (or firing it manually).

    http://kaspars.net/blog/wordpress/new-plugin-minit

    Report

  7. Thomas Herold

    It did not produce any better results on my website. There is another very good plugin, which does the same here:
    http://wordpress.org/plugins/autoptimize/

    Report

    • Ryan Hellyer

      That just uses buffering to scan the page rather than relying on the internal wp_enqueue API to build the code up.

      Report

      • Skip

        Help! What does that mean? I guess that fact I’m asking the question means I shouldn’t go near this? I use Autoptimize for minification and W3TC to do what I can in other areas.

        Report

        • Ryan Hellyer

          It just means they’re loading the entire page, then stripping out the existing CSS, combining it into a new minimised and concatenated file and serving that. It’s okay if you are using heavy static caching, but if you want dynamic content, then you are probably better off just serving the files as is, as the extra load from processing all that data on each page load could cause more problems than just serving the extra static files.

          Actually, that’s just a guess on my part. I’ve never sat down and measured the difference. At any rate, it’s a hacky way to do it, the plugin mentioned in this post uses a more sane approach.

          The downside to using a more sane approach, is that if a plugin or theme doesn’t use wp_enqueue to load the CSS or JS file, then it won’t get concatenated. But such plugins/themes are crappy and you shouldn’t use them anyway ;)

          Report

          • Skip

            Thank you Ryan, maybe I’ll disable Autoptimize, clear my caches and see how it measures up on Gtmetrix just with the other W3TC and my CDN running. As has been said before it’s an area that just breaks things but for amateur bloggers who rely on plugins with a bit of self coding occasionally it’s a scary and complicated topic – especially when writing to databases gets mentioned. I find it really interesting though. Thanks again.

            Report

          • Ryan Hellyer

            GTMetrix will likely show a better result for a well concatenated/minified page since it doesn’t measure server load. This sort of thing is very difficult to measure accurately.

            Report

          • Ryan Hellyer

            Sometimes just keeping things simple is best. I’ve seen quite a few instances where I’m fairly sure a user has made their site slower by attempting to add extra layers of caching.

            A simple static cache in front of WordPress does 99% of the work for most people.

            Report

  8. Patrick

    What a coincidence! I was just going to look into minifying resources on my site today and this article pops-up on my dashboard!

    I’ve installed the plugin on my development site and started browsing and clicking around, but Google page speed insights is still telling me I haven’t minified any of the resources which the plugin tells me I have…any ideas??

    Report

  9. partha

    Every time i learned a lot from here. Thanks.

    Report

  10. Jeff Chandler

    In my experience of using things that minify stuff, they’ve usually broken my site. I understand the purpose of minifying, but I’d rather have a working site than a bunch of stuff broken. If I remember correctly, W3 Total Cache has an option to minify scripts which caused a lot of things to break.

    Report

    • Topher

      This is almost always because one or more of your CSS sheets is being pulled in via @import, and those get skipped, effectively removing them from your site.

      That’ll make things look ugly. I recommend changing those sheets to be included properly via enqueue.

      Report

    • Marcelo

      Yep, minification is not something you can actually take lightly. There is a number of things that can -and will- break if you minify and concatenate files indiscriminately. That is why W3TC plugin has a lot of options, cause usually you will wreak havoc on any website by minifying and concatenating things. Unless you use twentyfourteen theme with almost no plugins, your site will be screwed.
      The best minification option I found to work is just minify HTML files, carefully. At least, if you have a very huge website, your cached files will be 15-20 MB smaller :) Not a great deal.

      Report

    • Anh Tran

      I always had problem minifying and concatenating JS/CSS files. Websites were broken many times. I tried a lot of minify plugins but none worked for me. I’ll give this plugin a try, looks like it does the job in a native WP way, hope it works well.

      Report

  11. Pablo Cruz

    It is a good plugin but It doesn’t work nice with background-image when it is relative to stylesheet URL, cause the resulting minified file is located in a new directory. Thanks!

    Report

  12. fadingad

    Non of my slideshows work. How do I uninstall Dep Min?

    Report

  13. Trevor

    For some reason the plugin is generating a path that is missing the / at the start of the path for the concatenated files… and so the path I get is: http://testwp.localhost_minify/……. instead of http://testwp.localhost/_minify/…..

    You can hack the plugin and add a slash on line 36: const DEFAULT_ENDPOINT = ‘_minify’; but that’s never a good idea.

    I tried for now to at least use a filter to change this option but it seems to have no effect…

    function my_minify_option( $options ){
    $options = array_merge( $options, array( ‘endpoint’ => ‘/_testing/’ ) );
    return $options;
    }
    add_filter( ‘dependency_minification_options’, ‘my_minify_option’ );

    It’s a bummer because otherwise this looks to be a great simple clean way to minify and concatenate.

    Any one else having this slash issue? Am I missing something obvious with my filter? I duplicated a filter example right from the plugin author so I thought it should work.

    Thanks!

    Report

Comments are closed.

%d bloggers like this: