Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Related Plugin Resources
Index

Comparing compression tools


We have covered three of the most popular compression tools. Each tool has its pros and cons. As always, the right tool for you is the one that best fits your needs. The following table summarizes the results, in bytes, you can get compressing a RequireJS file itself with the tools we just discussed:

File

Original size

Compressor

Size

RequireJS

82944

UglifyJS2

24576

Google Closure

13312

r.js

15360

As you can see, in this example, Google Closure yields the best result, but that is not always the case. If you run the same tests on the popular RaphaelJS library, you get the best result with Google Closure Compiler instead. The results vary depending on the source code writing style; for this reason, there is no single best tool to use. I prefer r.js because it can run the compressor engine as well as handle the plugins and module dependencies very well.

JavaScript task runners such as Gulp or Grunt can be used to create tasks to link, compress, and concatenate...