Cyber Monday Deal : Flat 30% OFF! + free self-paced courses  - SCHEDULE CALL

- Java Blogs -

What are the Benefits of loading jQuery from CDN

JQuery is not a programming language that was released in 2006 by John Resig. In fact, this is a well written Java library to simplify traversing between HTML documents, event handling, animation process, or Ajax interactions for easy web development. When you are planning to work with JQuery, you should be aware of basics of HTML, CSS, and JavaScript.

Licensing – This is an open source project licensed by both MIT and GNU. If you have used Microsoft IDE 2010 for Visual Studio then you can see jQuery has already been integrated into the program and easy to access by users worldwide. As a result, jQuery has been declared an official integration for IDE Visual Studio 2010.

In this tutorial, we will discuss jQuery basics and how to use it along with your program to increase overall productivity and functionality. JQuery is well written compact JavaScript code enables developers to manage critical UI functionalities by writing the small number of code lines only. In this way, the JavaScript library not only increases the overall productivity of developers but minimizes overall development time too.

Why has JQuery become immensely popular in short time span only?

  • JQuery improves overall performance and reliability of an application.
  • With this JavaScript library, you may develop responsive web pages compatible with all popular browsers.
  • This is much faster and takes really less time to execute queries.
  • For complex UI functionalities, you don’t have to write hundreds of code lines but same work can be completed with the small amount of codes only.
  • If you wanted to implement custom behavior then jQuery can be quickly extended to multiple classes.
  • If you are familiar with the basic syntax of Javascript language then you don’t have to write the fresh syntax for the jQuery program. You can use the same syntax for your application.
  • The code is really simpler and clean. It can be understood with ease without putting extra development efforts. Anyone can learn this program quickly with a basic understanding of HTML, CSS, and JavaScript language.
  • JQuery increases the overall productivity of developers and optimizes overall execution time too.
  • JQuery can be downloaded from its official website for free and it can also be availed as an official integration of IDE Visual Studio 2010.

How to load jQuery file in your web page


<script type="text/javascript" src="jQuery-1.4.1-min.js"></script>

The simple code allows you to include jQuery file into your web page. This code is generally written under the <head> </head> tag or you may use anywhere you want it.

Few questions related to jQuery scripting code, you should know about

1). How these two extensions are different - jQuery-x.x.x.js and jQuery.x.x.x min.js?

Based on functionality, the meaning of jQuery-x.x.x.js and jQuery.x.x.x min.js is same. But if we talk about the performance then they should be used carefully.

Read: What Is The Process To Run A Java Program In CMD?

2). Do JQuery file should be loaded in both master/template and content page.

Master/Template page is designed with an objective to create a consistent look for an application. However, if you have loaded jQuery file into the master page then it should not be referred into a content page. In short, jQuery file should be loaded only once either into a master page or content page otherwise it may result into the error.

3). How jQuery affects performance?

The overall size of a file is really small that can be downloaded in seconds. Also, it is faster and takes less time to create highly complex UI functionalities.

4). Is there any recommended version that should be used for app development?

Almost all versions are same; just more features are added to make it better and faster. Obviously, you should always use the latest version that can deliver maximum features and functionalities. By availing latest version, you can make sure that earlier functionalities are still working and you can use additional features too.

5). What will happen if I use the previous version and the latest version is available in the market?

Don’t panic. This will not affect product performance at all. Even if you are using the older version, web pages can be accessed in the same way as earlier. In case, you wanted to use some functionality that is defined for newer version only then you have to upgrade for the latest version.

How to load jQuery from CDN (Content Distribution Network)?

CDN is a group of multiple computers that are connected somehow with similar data files. The user can access the file from computer server nearest to its location and it makes overall access to web pages easy and faster. Clients don’t have to access the same server that optimizes latency time and you don’t have to wait for particular web page more as it was done earlier. In this way, overall performance and reliability over the network have been increased positively.

Read: Difference between Array Length vs String Length () Function in Java

1). Loading jQuery from AJAX CDN – Microsoft

By including this simple code in your web page, you may quickly load jQuery file from Microsoft AJAX CDN (Content distribution network). You can use this code anywhere but this would be great if this is written under the <head> </head> tag.


<script type="text/javascript" language="Javascript" 
	src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"></script>

2). Loading jQuery from Libraries API – Google

By including this simple code in your web page, you may quickly load jQuery file from Google Libraries API (Application programming interface). You can use this code anywhere but this would be great if this is written under the <head> </head> tag.


<script type="text/javascript" language="Javascript" 
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
</script>

What are benefits of loading jQuery from CDN?

You must be thinking why jQuery should be loaded from CDN when it is available on your own server. The answer is really simple and logical too. When any web page is accessed through server then cache copy is stored on your system for quick access of files. The same concept is true for content distribution networks too. The pages or jQuery files that have been accessed earlier can be loaded quickly than you ever expected. The browser will access the cache copy and it doesn’t have to be loaded again.

  • The jQuery file loading gets faster and easy.
  • It saves you data bandwidth as you don’t have to load jQuery file again.
  • CDNs stores same files on different geographical location so that it can be accessed by computer nearest to your location.

JQuery code execution

There are two popular ways how jQuery code can be executed –

1). Execute the jQuery code as soon as file gets loaded

Read: A Complete ReactJS Tutorial in 2023

<script language="javascript" type="text/javascript">
$(function () {
$("#div1").css("border", "2px solid green");
});
</script>

or


<script language="javascript" type="text/javascript">
$("#div1").css("border", "2px solid green");
</script>
  1. Execute the jQuery code when DOM objects have been loaded completely.

<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#div1").css("border", "2px solid green");
});
</script>

You May Like:

The first execution method may be faster but second technique is safer and recommended too. How jQuery should be used in your favor completely depends on developers. However, based on my personal experience I prefer second execution technique the most where the complete page has been loaded and I am just ready to play with elements.



fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

2 days 06 Dec 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

16 days 20 Dec 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

2 days 06 Dec 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

2 days 06 Dec 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

9 days 13 Dec 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

2 days 06 Dec 2024

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

13 days 17 Dec 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

2 days 06 Dec 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

17 days 21 Dec 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

10 days 14 Dec 2024

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

23 days 27 Dec 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

2 days 06 Dec 2024

Search Posts

Reset

Receive Latest Materials and Offers on Java Course

Interviews