public
Description: Rake tasks for merge and compress your stylesheets and javascripts
Homepage: http://lucaguidi.com/pages/assets_packager
Clone URL: git://github.com/jodosha/assets_packager.git
jodosha (author)
Mon Feb 23 06:26:48 -0800 2009
commit  777b501ccab5b17e9759ffb9ae6c0cbfa59e01e7
tree    5f51f427587b3b1625c65490b99bd0de165bcd5a
parent  1b90e1fdbd070819e8ece42875f18f3238851081
assets_packager / README
100644 71 lines (39 sloc) 2.21 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
AssetsPackager
==============
 
When you deploy your application it could be convenient to package all your
stylesheets and javascripts in a single file, let say all.css and all.js, in
order to decrease the HTTP requests against your server.
 
You may also find useful to reduce the size of those files, through a process
which eliminates all unneeded white spaces and comments.
 
AssetsPackager Rake tasks will help you in solving those problems.
 
 
 
= Installation
Copy assets_packager_tasks.rake under lib/tasks and jsmin under script/.
If you use Sprockets (http://getsprockets.org) copy assets_packager_sprockets_tasks.rake instead.
 
 
 
= How It works?
First of all, we need to generate a configuration file:
 
$ rake assets:config
 
Look for a file called assets.yml in your config directory and make sure the
order of listed files is the same you wish to have in your application
(i.e. prototype.js before of effects.js, or lowpro.js before of my_behavior.js).
Feel free of edit it.
 
We are now ready for merge and compress our files:
 
$ rake assets:package
 
 
 
Now, in your application make sure of use #javascript_include_tag and
#stylesheet_link_tag with the :cache => true option.
 
 
 
= Credits
AssetsPackager was strongly inspired by the homonym plugin written by
Scott Becker (http://synthesis.sbecker.net/), but I don't like the
approach used by him.
 
I don't like the idea of load a plugin for something I don't need in production
mode. In fact you should execute those tasks before your app will be started
(i.e. Capistrano post deploy task).
 
It also introduces new helpers (#javascript_include_merged) which substantially,
reproduce the same behavior of the :cache => true option.
 
Last, but not least, I don't like the naming system: base_1150571523.js
If you use Mongrel this means to have something like this:
 
<script type="text/javascript" src="/javascripts/base_1150571523.js?1150571523"></script>
 
Which sounds a bit redundant, if compared with all.js?1150571523
 
 
 
Uladzislau Latynski for his jsmin.rb Ruby porting.
 
 
 
Thanks to Steve Souder (http://stevesouders.com/) for his High Performance
Web Sites book.
 
 
Copyright 2008 - 2009 Luca Guidi - www.lucaguidi.com - Released under MIT License