What is JavaScript

189

Every website on the World Wide Web does, in one way or another, rely on JavaScript. But what is a script in the coding world and what does it mean to a web developer?

A script is basically a program that boosts interaction within a website be it launching pop-up menus or responding to every action a web visitor makes like checking out items on an online store. Initially, there were two kinds of scripts available, Java and VB, but most modern websites now run the popular JavaScript.

Ways to use JavaScript

There are only two distinct ways in which this script can be used; either as an external or internal script. An external script means the web developer stores the script language in a separate file then the HTML pages will access this file whenever required. On the other hand, an internal script means the web developer prefers to store the script files within the HTML document itself.

When to use internal and external JavaScript

External JavaScript is ideal where a created functionality is going to be accessed by multiple HTML documents at any given time. The web developer will thus keep the script in a separate file that will be used within the HTML documents. In code, this is normally introduced as extension .js within a <script> tag.

java-one

Then we have the internal JavaScript where the web developer decides to include the script as they develop the HTML documents in code. Normally the script is introduced as a header with <script> tag but there is no limit to the number of locations the script can be introduced within in a document. The code below explains it;

java-two

When not to use JavaScript

As explained before, JavaScript runs on almost every browser or website. However, there are still those sites or browsers that run on different scripts thus don’t recognize Java. This will register as an error, when the web user tries to open a page or use the search engine, to the end user in the form of an incomprehensible code.

To prevent this from happening, the web developer thus introduces HTML comments around the script to hide it from older browsers or HTML pages.

java-three

That is JavaScript in a nutshell, a programming language that helps web developers introduces interactivity in websites. JavaScript can be internal or external and how these two options are used solely depends on the web developer.

You might also like More from author

Comments

Loading...