5

Possible Duplicate:
How can I obfuscate JavaScript?

Hi,

I want to compress a JavaScript code but not just to remove whitespaces also I want to change all variable names to unintelligible names. How can I provide this ?

Thanks in advance,

Community
  • 1
  • 1
Barış Velioğlu
  • 5,709
  • 15
  • 59
  • 105
  • 2
    Side-note: *What you want to achieve is called obfuscation.* – Andreas Grech Jun 03 '11 at 08:52
  • In my opinion this is not a duplicate question. In this case the questioner does not know about the concept of `obfuscation` and hence put his question in another way. Even though, the solution to both questions is the same. – Ozair Kafray Jun 03 '11 at 09:00
  • 2
    @Ozair: Then it would still be a duplicate of: http://stackoverflow.com/questions/883184/ways-to-compress-minify-javascript-files – Felix Kling Jun 03 '11 at 09:03
  • @Ozair: Marking a question as a duplicate isn't dunning the person asking the duplicate (at least, not unless it's really blatant that the user has just completely not made any search effort at all), it's just about not having a lot of duplication on the site. – T.J. Crowder Jun 03 '11 at 09:18
  • [Online JavaScript Compressor Tool](https://compressjavascript.com/). It uses UglifyJS3 which is considered one of the best minifier. – Vianne Sep 01 '17 at 16:49

10 Answers10

1

Compressing is one thing, and the process of changing variable names to unintelligible names is called obfuscation. For that, you will need to use a javascript obfuscator or yuicompressor which does both.

Similar question(s) on SO.

  1. How can I obfuscate javascript?
Community
  • 1
  • 1
Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84
0

I recommend YUI compressor.

shinkou
  • 5,138
  • 1
  • 22
  • 32
0

Online Javascript compressor

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
0

Either of the following will serve you well:

http://code.google.com/closure/ and http://developer.yahoo.com/yui/compressor/

benjamunky
  • 260
  • 2
  • 12
0

just to add a bit http://code.google.com/closure/ can also be used

megakorre
  • 2,213
  • 16
  • 23
0

I'm quite fine with yuicompressor that obfuscate also

Eineki
  • 14,773
  • 6
  • 50
  • 59
0

I dont know if you tried googling it but this what i use:

Javascript Compressor

It is a good idea to have your code pass in JSLINT first to assure it works

Ibu
  • 42,752
  • 13
  • 76
  • 103
0

Or Uglify, an alternative to YUI compressor that requires node.js.

duffymo
  • 305,152
  • 44
  • 369
  • 561
-1

That is called obfuscation. Check out this question.

Community
  • 1
  • 1
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198