Reputation: 1225
I've been using Google's closure compiler, and I've heard that Google is also using it in their products.
Recently, I looked at Google Maps' compressed source code, and found out that string literals are pre-defined at the top.
# I've beautified in order to make it more readable
this._ = this._ || {};
(function (_) {
var window = this;
try {
'use strict';
:
var daa;
var caa;
var baa;
var aaa;
aaa = "\x00";
baa = "\n\nBrowser stack:\n";
caa = "\n//@ sourceURL=";
daa = '\nUrl: <a href="view-source:';
:
I think this is a good idea, because string literals written directly in source code will make hacking much more easier, and this solution can prevent it. Also, it can reduce script file size if long strings are used repeatedly.
I want to use this optimization in my project too, but I have no idea what options I should set to compiler. Are there any Closure compiler's options? Or else, are developers using some external tools to do this?
Upvotes: 0
Views: 102
Reputation: 14411
This is covered in the project FAQ: Closure Compiler inlined all my strings, which made my code size bigger. Why did it do that?
Upvotes: 1