Izumi Kawashima
Izumi Kawashima

Reputation: 1225

How can I enable header string literal declarations in Google Closure Compiler?

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

Answers (1)

Related Questions