Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minified JS and global variables

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
Can someone tell me that if I minify all my JS files, will global variables still function properly?

For example, given the below:

Code:
file1.js

var total = 50;


Code:
file2.js

var newTotal = total + 50;

Would this still work? This is a very basic example, most of my JS is contained within objects, but I do have numerous references to global variables.

Thx.
 
30+ JavaScript files that's why...

I am guessing the simple stuff will work but was hoping someone has already done this before.

Oh well. Looks like I have no choice.

 
I should have been more specific... minified as in white space removed, shortened variable names, etc. It is the shortening of variable names that is what I believe will create the problems.
 
Hi

Shortening the variable names should not cause any problem.

But personally I would not sacrifice the readability of my code just to reduce the size of script files, which are usually small anyway. At least compared to other resources.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top