Friendly Indian wrote:
How can I include a 'link' to javascript in a web page so all the javascript
code won't be readily accessible in the source view? I have a bit of code
and would rather not include it. with the html code. Thanks.
It depends on what you mean with "not include it". You *must*
include *any* script code that should have the chance to work,
only the methods of inclusion are different. You could use
<head>
...
<script src="$URI" type="text/javascript"></script>
...
</head>
to link an external script file containing the code.
But doing this only for the purpose of obscurity is nonsense. People
who want to get their hands on the code are usually smart enough to do
so. (Those who do not want to type the URI in the Location Bar just use
a bookmarklet.) The others are to stupid to re-use the code or simply
do not care about it.
Security by obscurity does not work. Your scripts are a work of mind
and as such copyrighted by law in most countries. You should instead
emphasize that fact (in a comment) and also include a license agreement
that specifies to what extent your code can be modified, re-used, and
distributed so that others can draw advantage from it or even can
improve it (so if the code is good your name spreads throughout the
hacker[1] community). See also: GNU General Public License (GPL).[2]
PointedEars, IANAL
___________
[1] Do not confuse hackers with crackers.
The former build, the latter destroy.
[2]
http://www.gnu.org/licenses/licenses.html#GPL