By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

Hide Javascript From View Page Source?

chunk1978
100+
P: 224
hi there,

so i vaguely remember viewing the source code to some internet sites, which appeared much shorter compared to the lengthy, complex content that was actually displayed... i'd like to know if there's a way to hide the script portion (or all portions) of an internet site from being viewed in a browser's "View Page Source"...

thanks.
Feb 21 '07 #1
Share this Question
Share on Google+
3 Replies

acoder
Expert Mod 15k+
P: 16,027
No that is not possible, because whatever techniques you use, anyone with some technical knowledge will be able to easily obtain your scripts. For example, you can use:
[HTML]<script src="js/myjsscript.js"></script>[/HTML] but I can easily download or view that script.

Other techniques to 'hide' javascript involves encoding it and also including a decoder, but that is never foolproof, e.g. see this link.
Feb 21 '07 #2

P: 35
Other techniques to 'hide' javascript involves encoding it and also including a decoder, but that is never foolproof, e.g. see this link.
Doesn't compressing your js make it harder to steal? Or is there a way to decompress it? Is the compression just the encoding that you linked to?
Feb 21 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Doesn't compressing your js make it harder to steal? Or is there a way to decompress it? Is the compression just the encoding that you linked to?
Yes, it does make it harder to steal, but if someone is determined enough, he can discover your algorithm and decode or decompress the code - that's why it's not completely foolproof. Remember you have to include the decode algorithm on the page.
For Javascript compression, you can look at this and Dojo's Shrinksafe (linked on that page).
Feb 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.