webserver, how to hide javascript directory

I have define root directory /var/www/html.  "index.html" is in that directory.  It references myjs.js in the /var/www/html/javascript/ directory.  

How do I prevent the user from seeing the javascript file ( https://myserver/javascript/myjs.js.)? I am using the Mongoose Webserver.
Who is Participating?
torimarConnect With a Mentor Commented:
You simply cannot prevent users from seeing javascript files. Javascript must be freely accessible for the user's browser in order to correctly display the web page. If it is accessible to the user's browser, it is also accessible to the user.
rgbcofAuthor Commented:
Is there a javascript command that pulls the javascript content into the html files.  I am OK with that.
You can place the complete javascript content inside your HTML file by including it between <script> tags:

<script type="text/javascript">
//JavaScript goes here

Open in new window

For more, please see here: http://www.howtocreate.co.uk/tutorials/javascript/incorporate
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

rgbcofAuthor Commented:
Thank.  I just want to know if hidding javascript was possible.
As I said, it isn't. Developers who want to 'protect' their intellectual 'property' often turn to "obfuscating" the code by using tools on it that make it humanly unreadable.
But even then it is still fully functional and may be copied and used by anybody else. Needless to say, users could also pass it through "unobfuscating" tools.

Generally, obfuscation is not a recommendable practice because it is mainly used by malware authors. So if you did it, your code would become suspicious.

rgbcofAuthor Commented:
Thanks for the obfuscation and the warning against using it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.