HTML and JavaScript tips and tricks :hiding JavaScript code by using external .js files
If you have written your javascript code on your web page then any visitor of your web page can easily find your javascript code from web page source.If you have written great script in JavaScript and you don't want to share it with everyone, you can hide it from the web page source by using the src attribute of <script> tag.
For this just put your javascript code in a text file and name this file as Myscript.js.
Here Myscript.js is the name of the file containing your JavaScript code.Though this JavaScript code is not displayed when you view the page source, but smart visitors can check their cache and can find this external JavaScript file there or they can download your javascript file.
If you have written your javascript code on your web page then any visitor of your web page can easily find your javascript code from web page source.If you have written great script in JavaScript and you don't want to share it with everyone, you can hide it from the web page source by using the src attribute of <script> tag.
For this just put your javascript code in a text file and name this file as Myscript.js.
<script src="Myscript.js" type="text/javascript"> <!-- //--> </script>
Here Myscript.js is the name of the file containing your JavaScript code.Though this JavaScript code is not displayed when you view the page source, but smart visitors can check their cache and can find this external JavaScript file there or they can download your javascript file.