Ahmad Oriza
Ahmad Oriza

Reputation: 15

is there way to compress javascript with my own method?

I wanna know, is there a way to compress javascript with a method that cannot be easily uncompressed by another?

I have used some tools like jscompress and other products. They're nice and useful, but they provide methods to uncompress/decode script too. The problem is other programmer or maybe hacker, can easily uncompress my script, the impact is my js ajax link, variable can be seen by the hacker. You know that what happen if they found our link. Maybe post direct value via ajax etc.

Upvotes: 0

Views: 63

Answers (2)

Ray Toal
Ray Toal

Reputation: 88378

If by your question you mean that you do not want the variables and Ajax links in your script to even be accessed by others ever, then you are talking about encryption, not just compression.

If the code was truly encrypted so that the Ajax links were not recoverable, the browser could not decrypt and therefore not even execute the script.

Obfuscators will make your code fairly illegible, but you are not going to be able to hide destination URLs in Ajax calls from hackers. All one needs to do is look at the browser's developer tools and watch the network calls.

It's important to design your application with the assumption that users and hackers are able to see all the JavaScript. If you can keep it secure under these conditions, that's ideal.

So if the question is just about making your code hard to read, obfuscate. But the kind of security you seem to be asking about needs to be done server side.

Upvotes: 2

Andrew Templeton
Andrew Templeton

Reputation: 1696

There is not a way to do this in client side javascript, it is inherently insecure. You should be using a call on your server to hide your API key.

FAQs from the w3:

http://www.w3.org/Security/faq/wwwsf2.html

Upvotes: 3

Related Questions