jQuery Difference between internal and external script

jQuery Difference between internal and external script

Today, We want to share with you jQuery Difference between internal and external script.
In this post we will show you jQuery Difference between internal and external script, hear for jQuery Difference between internal and external script we will give you demo and example for implement.
In this post, we will learn about jQuery Difference between internal and external script with an example.

The rule is simple: According to me,All The js-script should be external file used. Both for maintenance mode and performance mode.

Internal scripting :

  • Are loaded in the same page means itself so is not necessary to trigger another page request.
  • Are executed or run mode immediately and fast.
  • The async data and defer data attributes have no effect
  • It Can be helpful when you are using a server-side script dynamic rendering.

Internal scripting(itself) means writing mode to some the script functions available in the same HTML tag/page or Same PAGE itself.

index.html

<!doctype html>
<html lang ="en">
<head>
<title>internal vs external javascript : pakainfo.com</title>
</head>
<link rel="stylesheet" type="text/css" href="pakainfo/css/style.css"> 
<p onclick=alert("WELCOME to Angularjs My blog: pakainfo.com")>www.pakainfo.com</p>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
</body>
</html>

In the above simple example, onclick function has been declared in the HTML p tag itself.

External Scripting: Javascript

  • Gives better separation and best of concerns and useful of maintainability means structure.
  • The async data and defer data attributes have same effect so if this some attributes are present mode the js-script will change all the default behavior.and then This is not possible any with inline data js scripts.
  • Once a external script is downloaded and used any other the browser store it in the cache memory so if another page reference and used some web-apps it no additional download is required.
  • It Can be used to load time to client code on demand and some reduce overall data download time and size.

Here show to External scripting (Javascript or jQuery) means keeps the include script in a separate onther separate js file.

index.html

<!doctype html>
<html lang ="en">
<head>
<title>internal vs external javascript : pakainfo.com</title>
</head>
<p id="datavalue">www.pakainfo.com</p>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>

main.js

$('#datavalue').click(function() {
	alert("Welcome");
} );

Your Web-Application Writing the script(any js) in external file scripting way is the more best practice method.

The simple way to External js-scripting is preferable and more easy than the internal js-scripting. pure reason we can use the some code effectively in show and (structure vise)execure external scripting than internal.

Development


Related FAQ

Here are some more FAQ related to this Article:

  1.   JavaScript Array filter Method Filtering Arrays
  2.   how to call javascript function in html & JavaScript Define
  3.   jQuery Ajax Delete Request with Laravel
  4.   jquery uncheck all checkboxes Multiple Checkbox Example
  5.   javascript object Remove key value Examples
  6.   remove last character from string javascript
  7.   how to upload image in php and store in database and folder?
  8.   how to call javascript function in html?
  9.   VueJS setTimeout() Function Examples
  10.   call javascript function from html