Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  79] [ 2]  / answers: 1 / hits: 15500  / 15 Years ago, tue, october 27, 2009, 12:00:00

How do I hide my javascript/jquery scripts from html page (from view source on right click)? please give suggestion to achive this .



Thanks.


More From » jquery

 Answers
66

Your best bet is to either immediately delete the script tags after the dom tree is loaded, or dynamically create the script tag in your javascript.



Either way, if someone wants to use the Web developer tool or Firebug they will still see the javascript. If it is in the browser it will be seen.



One advantage of dynamically creating the script tag you will not load the javascript if javascript is turned off.



If I turned off the javascript I could still see all in the html, as you won't have been able to delete the script tags.



Update: If you put in <script src='...' /> then you won't see the javascript but you do see the javascript file url, so it is just a matter of pasting that into the address bar and you d/l the javascript. If you dynamically delete the script tags it will still be in the View Source source, but not in firebug's html source, and if you dynamically create the tag then firebug can see it but not in View Source.



Unfortunately, as I mentioned Firebug can always see the javascript, so it isn't hidden from there.



The only one I haven't tried, so I don't know what would happen is if you d/l the javascript as an ajax call and then 'exec' is used on that, to run it. I don't know if that would show up anywhere.


[#98447] Wednesday, October 21, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breap

Total Points: 606
Total Questions: 96
Total Answers: 108

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
breap questions
Thu, Jun 24, 21, 00:00, 3 Years ago
Wed, Mar 18, 20, 00:00, 4 Years ago
Mon, Oct 7, 19, 00:00, 5 Years ago
;