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 8737177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:27:34+00:00 2026-06-13T10:27:34+00:00

I have two js files: 1.js (function(){ function setLength(a,len){ a.length=len; } ……….. })(); 2.js:

  • 0

I have two js files:

1.js

(function(){
  function setLength(a,len){
  a.length=len;
}
  ...........
})();

2.js:

function View(){
  setLength(this,3);
}

Note,the 2.js will access the method (setLength) defined in 1.js.

So I want the compiler compile these two files using the same replacement.

I want this kind of result:

(function(){
  function x(a,b){
  a.length=b;
}
  ...........
})();

function View(){
  x(this,3);
}

Is this possible?

BTW,I use the compiler.js to compile the files:

java -jar compiler.jar --js file.js --js_output_file file.min.js

This is the single file,I want to compile more than one file and each have its own output file,something like this:

java -jar compiler.jar --js file.js,file2.js --js_output_file file.min.js,file2.min.js
  • 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-13T10:27:36+00:00Added an answer on June 13, 2026 at 10:27 am

    To compile these two files using the same replacement, two options of closure compiler can help

     
     --variable_map_input_file VAL          : File containing the serialized version
                                               of the variable renaming map produced
                                               by a previous compilation
     --variable_map_output_file VAL         : File where the serialized version of t
                                              he variable renaming map produced shou
                                              ld be saved
    

    So you can

    • First Compile 1.js and generate variable_map.

        java -jar compiler.jar --js 1.js --js_output_file 1.min.js -variable_map_output_file variable_map.txt
      
    • Second Compile 2.js with the generated variable_map.

        java -jar compiler.jar --js 2.js --js_output_file 2.min.js --variable_map_input_file variable_map.txt      
      

    If 2.js will reference functions defined in 1.js, then the complier will need an extern.js in order to compile 2.js

    And with the output wrapper (function(){%s})(), all functions defined in 1.js can not be accessed from 2.js. You might need drop the wrapper, or use export

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

Sidebar

Related Questions

Friends, I have two files, a.c and b.c . I have defined a function
So I have two files: File 1 has this method in it: import MyGlobals
I have a function that compares two files to see if they are the
I have two JavaScript files that contain a jQuery function with the same name
So I have two files, 'header.php' and 'pluginfile.php' The function that I want to
I have two files: cart_function.php function get_product_name($pid){ $result = mysql_query(SELECT product_name FROM product_table WHERE
I have two files like below SomeClass.php class SomeClass { public function display() {
I have two subtitles files. I need a function that tells whether they represent
I have two code files, one contains my WinMain() function, and all functions related
Say i have two files: One is called mainFile.lua: function altDoFile(name) dofile(debug.getinfo(1).source:sub(debug.getinfo(1).source:find(.*\\)):sub(2)..name) end altDoFile(libs/caller.lua)

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.