Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have jquery scripting code on every page and i don't want to show it public ,so i want it to minimize for security and better performance .the minimizing action should be perform when page loaded over a browser .
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-15 21:55pm    
I would not take it as "security" measure. No matter what you do, you cannot avoid showing script to public. As the JavaScript works on the client side, it is shown to public by definition. Obfuscation can be used, but it should not be considered as "security".
—SA

Put your js in separate files and use bundling

http://www.asp.net/mvc/overview/performance/bundling-and-minification[^]

If your js won't go in a separate file then refactor it so it will.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Jun-15 22:02pm    
5ed, but see also my 5 cents in Solution 3.
—SA
Minify your resources - Minify Resources (HTML, CSS, and JavaScript)[^].
Try out what is JavaScript minification[^] to understand that while size of files are compressed for performance, the files will still be available to the public to view in their browser.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Jun-15 22:03pm    
5ed, but see also my 5 cents in Solution 3.
—SA
Abhinav S 20-Jun-15 23:39pm    
Thank you.
In addition to Solution 1 and 2:

Minimizing the traffic of the scripts can be a good thing, but… Please see my comment to the question. It's purpose is to convince you not to consider obfuscation as a security measure. It can be considered as one of kinds of security through obscurity. If you think it's pretty good and makes practical sense, think again. Read, for example, this:
https://en.wikipedia.org/wiki/Security_through_obscurity[^].

As to the practical considerations, I don't think what you called "security" is really related to security. I would rather think that you don't want others to steal your script code. Here, I would advise to think at simple practical consequences of it. If your code is really valuable so some people would badly want to steal it, your obfuscation cannot stop them, because your full code will always be on the client side, and other people won't even try to look at it.

—SA
 
Share this answer
 
Comments
Abhinav S 20-Jun-15 23:39pm    
5.
Sergey Alexandrovich Kryukov 20-Jun-15 23:48pm    
Thank you, Abhinav.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900