Help - Search - Members - Calendar
Full Version: How To Hide A Js File
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
wizkid0319
my problem is that i have a .JS file in my root folder which is used to do some processing. and if some one get to know the file name he can type the file name and get the source of that file. so i would like to know a way to restrict that. but i cant disable CHMOD gropuaccess read permission. coz then the application stops working as well... pls help....
urgent...

cheers
ipsauron
Its hard to hide a .js file because in every browser people can "right click>show source" and get the link to your .js file in your pages source code (shows html only).

But theres probaly some .htaccess script you use.
Banjo
Use a source hiding script.
Ed
Due to javascript being a client side script, you can't 'hide' your source, what you can do is obfuscate it so it's not as easy to read, but it's by no way fool proof.

I googled and came up with this:
http://daven.se/usefulstuff/javascript-obfuscator.html

There's a lot out there, but I've bumped into a few commercial ones too.

If you need to protect it so badly, then you should opt for a server side language to do the sensitive parts.
berryscary1
QUOTE(Bread @ Apr 15 2008, 10:38 PM) *
Due to javascript being a client side script, you can't 'hide' your source, what you can do is obfuscate it so it's not as easy to read, but it's by no way fool proof.

I googled and came up with this:
http://daven.se/usefulstuff/javascript-obfuscator.html

There's a lot out there, but I've bumped into a few commercial ones too.

If you need to protect it so badly, then you should opt for a server side language to do the sensitive parts.

You said to opt out the sensitive parts with server script, so can you send variables from something like php to javascript?
rvause
http://scriptasylum.com/tutorials/encdec/encode-decode.html

I use a method when I write something at work... similar to what is described here
zymic55
QUOTE(wizkid0319 @ Apr 15 2008, 07:33 AM) *
my problem is that i have a .JS file in my root folder which is used to do some processing. and if some one get to know the file name he can type the file name and get the source of that file. so i would like to know a way to restrict that. but i cant disable CHMOD gropuaccess read permission. coz then the application stops working as well... pls help....
urgent...

cheers


Please use PHP file as a JavaScript by adding the following header.
header("Content-type: application/x-javascript);

Then write down the actual JavaScript code between PHP here document tags.

PHP can give the unseen JavaScript output to the client side, but the PHP source itself cannot be downloadable.
hence your source code is protected.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.