YUIcompress: A Plugin for Panic’s Coda

I've spent the last few weeks compressing a lot of CSS and JavaScript files, don't ask me why, I just have. And, at some point the work became too tedious. I googled for a Coda plugin that would make my life a whole lot easier by automatically compressing (using the YUI Compressor) and saving my files. But, to my surprise I found nothing of the sort. So, I figured I would give plugin creation a go, and YUIcompress was born.

Updated to version 0.2 on May 20, 2010.

How it works

  1. Download and install the plugin.
  2. Open the file you wish to compress (css or js).
  3. Select YUIcompress from the Plug-ins menu or press command + shift + Y.
  4. Voilá! You should now have a compressed file with the name {filename}.min.{js|css} in the same directory where the uncompressed file is located.

Don't blame me!

Feel free to download, share, and use YUIcompress, just don't blame me if something goes horribly, horribly wrong. Depending on the file size, you may get the infamous beach ball for a few seconds, but nothing should break. I have used the plugin for a couple of weeks now, and nothing has happened to me or my computer, not yet at least.

24 Responses to “YUIcompress: A Plugin for Panic’s Coda”

  1. Gravatar
    Works like a charm Bedrich, thanks for sharing!

    » Cesar

    04/30/2010 5:45 pm

  2. Gravatar
    Very nice. Although it doesn't seem to work on files when connected to a remote server.

    » Patrick

    04/30/2010 9:27 pm

  3. Gravatar
    That's a very good idea although it doesn't work for me. I tried with both CSS and JS, in different folders, but no minified file is created. I have 10.6.3 and Coda 1.6.10. Tell me if you have a solution. Thanks.

    » LeBen

    05/02/2010 1:29 pm

  4. Thanks all for being brave, and trying this out :D
    @Patrick You are right, it doesn’t work on remote files since it runs the YUI Compressor command on the Terminal's local shell. I believe the LESS Compiler plug-in has the same problem, but I will investigate further.
    @LeBen Hmm, I have the same setup and it works fine for me. Could you try saving the files first, and then giving it a go?

    » Bedrich

    05/02/2010 2:39 pm

    Gravatar
  5. Gravatar
    Yep, I tried saving first but it doesn't work. Don't waste your time for me, I'll continue to minify them manually ;-) Thank you anyway.

    » LeBen

    05/04/2010 3:41 pm

  6. @LeBen
    The only other thing I can think about is file permissions. Sorry I can't be much help, not really sure what's wrong :\

    » Bedrich

    05/04/2010 10:16 pm

    Gravatar
  7. Gravatar
    Thanks! This is awesome.

    » Blaze

    05/13/2010 9:27 am

  8. Gravatar
    Great, thanks! One thing: Doesn't work on files containing more than one dot in their name (e.g. my.javascript.file.js).

    » Timon

    05/20/2010 5:53 am

  9. @Timon
    Thanks for bringing that bug to my attention. The problem has been fixed and the plugin updated.

    » Bedrich

    05/20/2010 1:38 pm

    Gravatar
  10. Gravatar
    it used to work, but now it's not. it freezes my coda. i think coda just released an update maybe? man i loved this plugin, any ideas?

    » Chuck Pearson

    06/18/2010 12:52 pm

  11. @Chuck
    Things are still working for me and I'm running 1.6.11, which I think is the latest release. Are you compressing a CSS or JS file? How big is the file? The latter could cause the beach ball to appear but it shouldn't crash things. Any other clues you can give me will help in solving your issue. Thanks.

    » Bedrich

    06/18/2010 1:21 pm

    Gravatar
  12. Gravatar
    Hey, thanks for responding. I'm running 1.6.11 too. I'm trying to convert my screen.css file which is 246kb. The beach ball appears and I can't do much else. I have to eventually force quit and when I reopen coda, the screen.min.css is there, but I don't trust that it's fully correct, so I just trash it. I'm not sure why it's locking up, as it never has in the past.

    » Chuck Pearson

    06/18/2010 2:17 pm

  13. @Chuck
    Quite a large CSS file :) My guess is that its size is making the beach ball appear and Coda freeze. The one way to know for sure is to test the plugin with a smaller file and see what happens. I will look into the code and see if there is something I can do to improve performance.

    » Bedrich

    06/18/2010 3:19 pm

    Gravatar
  14. Gravatar
    Yes, it is, hence the reason we want to compress it :) It's for a huge app, so it's somewhat expected. I'll try a smaller file to test.

    » Chuck Pearson

    06/18/2010 4:50 pm

  15. Gravatar
    Ok, apparently coda just released an update for .12 and now everything seems to be working fine again, on the same file. So I guess I'm good. :)

    » Chuck Pearson

    06/18/2010 4:53 pm

  16. @Chuck
    Awesome! Glad to know the problem was solved with the update and that the plugin is coming in handy for you and your team. Cheers.

    » Bedrich

    06/18/2010 5:18 pm

    Gravatar
  17. Gravatar
    Hi Bedrich. Great plugin. I don't know how plugins work on Coda, whether it's possible to have options in the preference pane but I have some small ideas that would really improve it and help me automate things.

    » Adam

    07/06/2010 3:19 am

  18. @Adam
    Glad you like the plugin! I'm pretty sure preference menu panes cannot be added for a plugin but sub-menus could do the trick, that is, depending on what you have in mind :)

    » Bedrich

    07/07/2010 9:37 am

    Gravatar
  19. Gravatar
    Hmm.. It doesn't seem to work anymore. Has something changed? I'm running Coda 1.6.12

    » Blaze

    07/16/2010 9:07 pm

  20. @Blaze
    Hmm…not sure what could be wrong, I am also running 1.6.12 and things work well for me. @Chuck had some problems when he was running 1.6.11. Anything more specific to your problem? Is the app crashing? Or, is the .min file not appearing?

    » Bedrich

    07/19/2010 12:33 pm

    Gravatar
  21. Gravatar
    Brilliant! Thanks.

    » Joe

    08/04/2010 12:12 pm

  22. Gravatar
    Hi Bedrich, sadly I have also the problem that no .min file is created. :( Using the latest version of Coda, latest version of your plugin, latest Snow Leopard on MBP. Simple filename (main.js, 12k) on local drive in my home dir. Used the hotkey and the menu entry. For a second I see the waiting cursor the first time I call YUICompress, but nothing happens and nothing crashes. Cannot find any *.min file anywhere else on the harddisk. Tried other different js files as well. If you have an idea what to try, I will gladly help out tracking down the problem.

    » Theo

    08/10/2010 3:22 pm

  23. Gravatar
    I'm having the same problem as Theo. The plugin seems to be working a bit, but then no .min file appears.. :/

    » Blaze

    09/01/2010 6:04 am

  24. @Theo, @Blaze, perhaps a permissions problem on the folder you are trying to write the .min file to? I'm not really sure what else could be causing the problem. Any more details about the file, or the file itself, would be helpful :)

    » Bedrich

    09/03/2010 2:46 pm

    Gravatar