Responsive: Minifying JS/CSS files

59 views
Skip to first unread message

Clair

unread,
Aug 15, 2013, 4:00:55 PM8/15/13
to joindin-d...@googlegroups.com
Hi all

One of the things I'd really like to do for our rewrite is to keep download size as small as possible, and I think an easy win to do this would be to minify any javascript (and potentially CSS) files on build

This isn't something I've any experience setting up, so I'm throwing it out there. Has anybody done this before - or has anybody read any good ways to minify files on build without needing the developer having to do it manually to check their work on their own machine - so development (maybe default?) installations would still use the "regular" version of the file(s)

Some technical details:
- The server we use already has Java installed, and so YUI (http://yui.github.io/yuicompressor/) seems like a good choice (but I don't think that means we /have/ to use YUI)
- There's only one CSS file so far, and a couple of Javascript files. I'm extremely open to changing how we include these files - I'm of the opinion that using jQuery and the jQuery plugin architecture (to keep things modularised) will be a nice way to do things, but we also need to keep 3rd party libraries (such as the maps library we're using) in mind
- We have a flag in the config file for development mode

Does anyone have any thoughts/ideas/concerns?


Clair

Walter Ebert

unread,
Aug 19, 2013, 4:58:26 PM8/19/13
to joindin-d...@googlegroups.com
Hi Clair,

A possible solution would be to use Assetic, which is available as a
Twig extension:
https://github.com/kriswallsmith/assetic#twig

Regards,
Walter
> --
> You received this message because you are subscribed to the Google
> Groups "joindin-developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joindin-develop...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


lornajane

unread,
Sep 9, 2013, 8:39:01 AM9/9/13
to joindin-d...@googlegroups.com
Walter - thanks for the suggestion, I think it's a good one :)

Okay, I've got something similar going on with my current client project so I know a bit more about this than I did previously and I thought I'd try to keep this idea moving within the group.  I like Assetic from what I've seen so far and I'm implementing it with Slim at the moment, to serve concatenated-but-not-compressed files on the development platform and concatenated-and-compressed files on the live platform.  Assetic provides a really nice way to add assets and then set up what process to put them through.  Since we'd be deploying from the build server, and that already has Java since we use Jenkins, the YUI compressor looks like a good option.

The way I understand the mechanics is that we just include CSS and JS as being at particular URLs - and what is actually there is some PHP that then produces the right thing.  We set the cache headers so that browsers aren't hitting that on every request.

Does this sound like a plausible way to proceed?  Clair - just think about whether you think it's an idea, we can round up some help to actually implement it if we need to!

Lorna
Reply all
Reply to author
Forward
0 new messages