HTML and CSS Reference
In-Depth Information
Listing 15.87 Installing Juicer and YUI Compressor
$ gem install juicer
$ juicer install yui_compressor
Run from the root of the Node.js application, the command in Listing 15.88 will
produce a single file, chat.min.js , containing the entire client-side application.
Listing 15.88 Using Juicer to compress files
juicer merge -s -f -o public/js/chat.min.js \
public/js/function.js \
public/js/object.js \
public/js/tdd.js \
public/js/observable.js \
public/js/form_controller.js \
public/js/user_form_controller.js \
public/js/json2.js \
public/js/url_params.js \
public/js/ajax.js \
public/js/request.js \
public/js/poller.js \
public/js/comet_client.js \
public/js/message_list_controller.js \
public/js/message_form_controller.js \
The final result is a 14kB JavaScript file containing a fully operational chat room.
Served with gzip compression, the total download should be about 5kB.
Juicer is also able to find dependencies declared inside script files, meaning that
we can jot down each file's dependencies inside comments in them and then simply
run “juicer merge chat.js” to produce the complete file, including the dependencies.
More information on Juicer is available from the topic's website. 4
15.7 Summary
In this chapter we have been able to pull together a lot of the code developed
throughout this topic to create a fully functional, entirely JavaScript based browser-
based chat application. And we did it all using test-driven development, right from
the very start.
Search WWH ::

Custom Search