simple javascript question about imported js files

Status
Not open for further replies.

gobears368

Seniorius Lurkius
3
Hi all,

I have a quick question about javascript and javascript engines.

I know that if I go to an html page, that page gets downloaded by the browser onto my local computer and read by the browser. If that page includes the line "<script type="text/javascript" src="jsfilename.js></script>" what happens?

Does jsfilename.js get downloaded to my computer as well? If it is downloaded, is it downloaded in unmodified form, or does the webserver compile it to some sort of object code version that is then downloaded? If I looked in my browser's local cache, would I find the jsfilename.js file just as it exists on the web server?

thanks in advance for your help.
 
NavyGothic":3dj0ruoc said:
An external Javascript file will be downloaded in full plain-text format to your computer. Your browser will then interpret the code, and execute accordingly.

If you're worried about code being stolen or something similar, I think the only real protection is code obfuscation.

I would go far as to say, if you're worried about code being stolen, don't use JavaScript. If you just worried about all those naughty comments you wrote in your code, minification/obfuscation will do just fine. ;)
 

ahankinson

Wise, Aged Ars Veteran
117
I would go so far as to say: If you're worried about code being stolen, don't use the web. :)

Everything from the web is downloaded to your computer in some way shape or form: Flash files, images, CSS, Javascript. The web is (mostly) stateless, meaning that your browser opens a connection with the server, downloads all the stuff it needs, and then closes the connection. If you make a new request, it will open the connection again, download, and close. (This is a simplified view, but it holds for the most part.)
 

wb

Ars Legatus Legionis
25,208
Subscriptor
ahankinson":1aomverb said:
I would go so far as to say: If you're worried about code being stolen, don't use the web. :)

Everything from the web is downloaded to your computer in some way shape or form: Flash files, images, CSS, Javascript. The web is (mostly) stateless, meaning that your browser opens a connection with the server, downloads all the stuff it needs, and then closes the connection. If you make a new request, it will open the connection again, download, and close. (This is a simplified view, but it holds for the most part.)

To be fair, you can do proprietary stuff in server-side code.
 

drogin

Ars Tribunus Angusticlavius
8,283
Subscriptor++
gobears368":1mjoqk23 said:
I'm not worried about anyone stealing my code, but can someone elaborate more on minimization/obfuscation? what are those?

and how does server side js differ from regular js?

Re: Minification

Essentially, it is a form of compressing the code so that it gets from the server to the browser in less time.
 
gobears368":1kbshes6 said:
I'm not worried about anyone stealing my code, but can someone elaborate more on minimization/obfuscation? what are those?

and how does server side js differ from regular js?

Server side JS plays essentially the same role in the web stack as PHP, .Net, WebFrameworkDuJour, etc. In all cases, there is some code that runs on the server and generates output which is sent to the client's browser. The output is probably HTML, although maybe XML, JSON, or something like that.
 
Status
Not open for further replies.