[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • Last Modified:

JAVASCRIPT - in .js file and script

Hello!

Could you please explain me some features of the Javascript?

1. Which is the difference in use a .js file or into HEAD section?

2. How I use a .js file instead a js  into HEAD section?

3. It is secure the encryption of js? There is a way for reading it although encrypted? or for decrypt it?

4. If we want use several javascripts which is most useful? Into .js file or as script into HEAD section?

Thank you very much.

Letchev

0
letchev
Asked:
letchev
  • 3
  • 2
1 Solution
 
ZvonkoSystems architectCommented:
1.)
To use .js file assign src attribute in the <script> tag.
<script src="your.js"></script>

And to use in the head section simply add the script lines betwean <script> and </script>

2.) The difference is that .js file is in a separate file and can be called from several .html pages. If you enter the script lines in the head sections and want to change something, then you have to change all html pages instead of one .js file.

3.) There is no secure way to encrypt .js files. The reason is that the browser needs to be able to read the script. If would you be able to encrypt it that nobody can decrypt it, then also the browse cannot read it and execute.

4.) I would recommand to use .js files as offten as possible.

0
 
letchevAuthor Commented:
Thank you.

Regarding question "3" do you know the script for encrypt javascripts from:
http://www.dynamicdrive.com/dynamicindex9/encrypter.htm ?

What yoy thinks about this script for encrypt js script files?

Thank you again

Letchev
0
 
ZvonkoSystems architectCommented:
That is no encryption.
That is simplest use of escape() and unescape() functions of JavaScript.
That is poor mans method to hide the script from JavaScript novices.
What I wanted to say is that there is no way to make JavaScript encrypted, you can make it only difficult to be read by human beings. But browser needs to see the script to be able to execute the script.
If you need a bit more difficult script hiding in IE, then look for this:
http://www.microsoft.com/downloads/details.aspx?FamilyId=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en

And even for that, hackers interested in reading your code can even decrypt that encryption.
0
 
letchevAuthor Commented:
Thank you again

Letchev
0
 
ZvonkoSystems architectCommented:
You are welcome.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now