Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:31:01+00:00 2026-06-04T05:31:01+00:00

I am new in google closure compiler,and after read the documents in the closure

  • 0

I am new in google closure compiler,and after read the documents in the closure tools site,I create a js and make the test.

However I found that even I use the Advanced Compilation level,the compiled codes are still easy to decompilated.

For example,this is the codes:

//2
window["_NameSpace_"]={};
window["_NameSpaceInternal_"]={};
(function() {
    _NameSpaceInternal_.Class = function() {
        var clazz = function() {
            this["init"] && this["init"].apply(this, arguments);
        };
        var pros = {}, arg;
        for(var c = 0, k = arguments.length; c < k; ++c) {
            arg = arguments[c];
            if( typeof arg === 'function') {
                if(c == 0 && k > 1) {
                    var F = function() {
                    };
                    F.prototype = arg.prototype;
                    pros = new F;
                    arg = arg.prototype;
                }
            } else {
                if(arg.init) {
                    clazz = arg["init"];
                    delete arg["init"]
                }
            }
        }
        for(var p in arg)
            pros[p] = arg[p]
        clazz.prototype = pros;
        return clazz;
    };
})();

(function(d){
    d["Person"]=_NameSpaceInternal_.Class({
        "init":function(name){
            this.name=name; 
        },
        "whatever":function(aaa){
        }
    });
})(_NameSpace_);

After compiled(I make a pretty format for human reading):

window.__MapNS__ = {};
window.__MapNSImpl__ = {};
__MapNSImpl__.a = function() {
    function c() {
        this.init && this.init.apply(this, arguments)
    }
    for (var b = {}, a, d = 0, e = arguments.length; d < e; ++d) if (a = arguments[d], "function" === typeof a) 0 == d && 1 < e && (b = function() {}, b.prototype = a.prototype, b = new b, a = a.prototype);
    else {
        a.b && (c = a.init, delete a.init)
    }
    if (!b || !a) throw Error("You must provide an object to copy from and to");
    for (var f in a) b[f] = a[f];
    c.prototype = b;
    return c
};
(function(c) {
    c.Person = __MapNSImpl__.a({
        init: function(b) {
            this.name = b
        },
        whatever:function(x){
        }
    })
})(__MapNS__);

Now,taks the class defination for “Person” for example, after compiled,all the methods for “Person” are clearly for hacker even these method have to be exposed.

But I wonder if I can make the compiled codes like this;

...........
var xx="init",xxx="whatever",xxxx=="Person";
    c[xxxx] = __MapNSImpl__.a({
        xx: function(b) {
            this.name = b
        },
        xxx:function(x){
        }
    })

...........

Just like the google map’s compress.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:31:04+00:00Added an answer on June 4, 2026 at 5:31 am

    The exact answer you are looking for is to enable the AliasStrings pass in the compiler by either using the Java API or by making a custom build of the compiler. The pass is not enabled by default as it tends to produce larger code when accounting for gzip.

    To actually get the same effect that most google products achieve, you’ll need to make substantial changes to your code.

    1. Define your objects and methods in the global scope. Assign them to namespaces after declaring them globally. You can use the output_wrapper flag to wrap the compiled code in a function to prevent global scope collisions. Example:

      function a() {}; window['Namespace']['obj'] = a;

    2. Define your objects directly – don’t use a helper method. So instead of

      var a = _NameSpaceInternal_.Class({"init":function(name){ this.name=name; });

      You would use something like:

      function a(){}; a.prototype.name = ""; a.prototype.init = function(name) { this.name=name; };

      This avoids using quoted syntax and allows the compiler to rename your properties and methods.

    For many more examples of coding style that compiles/renames optimally with Closure-compiler, see the Closure Library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read about a new Google-code hosted (open source) project from Google that
First of all, I must say that I'm very new to Google Closure, but
I am new to Google Maps. I am trying to make a map that
I have been trying to create a new google custom search engine, but when
I recently switched to Google closure for a new project. I am having trouble
I'm using Google closure to create a simple interactive graphic in HTML/JS to be
I'm relatively new to the Google Closure library and my current obstacle is getting
I'm getting a weird error using google closure compiler. I'm using externs to indicate
i'm using google maps v3 and i want create a new map associate to
I have a service variable that is initialized : service = new google.gdata.calendar.CalendarService('timeless'); This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.