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

  • SEARCH
  • Home
  • 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 5946183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:47:11+00:00 2026-05-22T16:47:11+00:00

I have my own Javascript library, which I want to minify by using Google

  • 0

I have my own Javascript library, which I want to minify by using Google closure compiler with Advanced optimization. By looking at the docs I see how to declare functions which are used outside of the library.

However I couldn’t find a way how to preserve global variables declared in my library. Closure compiler just removes them, because it thinks they are never used. Anybody can help ?

Edit: example code:

var variable_1 = true;

This is defined globally right at the beginning of my library, but it’s never used in the library itself. It is used outside the library when it is included in some page. But that Closure compiler doesn’t know and thats the reason it removes these declarations.

  • 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-05-22T16:47:12+00:00Added an answer on May 22, 2026 at 4:47 pm

    The closure compiler cannot remove global variables declared as window["variable_1"] = true

    I recommend you write to window directly for global variables and I also recommend you use string literals for your variable names so that closure doesn’t minify it.

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

Sidebar

Related Questions

I have the javascript validation working good for my own code. I want to
I have just started writing my own JavaScript Framework (just for the learning experience),
I'm creating my own JavaScript Array-like object and I have methods that call closures.
I'm trying to hide window after its startup. I have own window-class which is
I have my own game engine using C++ and OpenGL, but I have models
I have my own custom Content Provider that loads a database which contains the
I've been working on my own javascript library, kis-js. I recently converted it to
I've been working on my own personal JavaScript library for a while now, and
I'm using a Facebook-like autocomplete jquery library found at: http://otisbean.com/dropbox/jquery.tokeninput.js In my own html
I have a textbox onin a masterpage which I'm using as a search box.

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.