javascript script load : linking js file

Posted under javascript sample code On By mohammed.mutawe

javascript script load

You may write JavaScript code on a common page with other HTML tags, and this is a good way to connect to all page resources without feeling slow in loading, but we may need to separate the JavaScript code in order to organize the pages well This is what we will implement when loading JavaScript script and embedding it in HTML tags.

 

Concepts

  • External JavaScript file.
  • Script tag.
  • Create first script.

 

Definition

Embedding a JavaScript file is very easy in an HTML environment. Create any file and change its extension to .js and be careful to put it in the local host files of your HTML page to become:

<!--External JavaScript File are same of javascript script load -->
<script type="text/javascript" src="yourfile.js"></script>

I know that in the future you will be attaching a lot of js files so it is better to organize your affairs well and put all the js files in the head tag in HTML.

 

Script tag

Do not forget to write any sudden code in the js file in html, you only need to include it in the js tag to become as follows:

<script>
JavaScript code here...
</script>

did you see that ? Things do not need to be complicated in web technology and these basics will greatly develop you in the future.

 

Create first script

Do not forget that the scripting tag can be included in any programming language, depending on the source from which we are explaining. You can include Visual Basic language or other programming languages, but I personally did not apply that.

It may be used in Microsoft asp.net and because I’m a JavaScript fan, I haven’t been familiar with including other languages, maybe JavaScript provides all of that.

<script type="text/javascript">
JavaScript code here...
</script>

Did you see that above? You will be able to include any language you want to perform the tasks of your page in the form of type and maybe we will apply more than one language in later private lessons.

A feature that many people may not know about in JavaScript is to put comments in the noscript tag to avoid using // or /**/ while writing comments, so it looks like this:

<script type="text/javascript">
    document.write("Hello World!");
</script>
<noscript>
    The color is Green.
</noscript>

 

References

  • Third edition JavaScript

Leave a comment

Your email address will not be published. Required fields are marked *