Special OFFER: 1st Enroll Flat 25% OFF OR 2nd Enroll Get 40% OFF | Use Coupon JTOFFER25

- 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 Difference between JavaScript and JQuery?

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: Java.net Connectexception connection refused

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" 

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" 

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: What Is The Process To Run A Java Program In CMD?

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


<script language="javascript" type="text/javascript">
$("#div1").css("border", "2px solid green");
  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");

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.

FaceBook Google+ LinkedIn Pinterest

    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.


Trending Courses


  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

-1 day 24 Sep 2021


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

Upcoming Class

-1 day 24 Sep 2021

Data Science

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

Upcoming Class

0 day 25 Sep 2021


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

Upcoming Class

6 days 01 Oct 2021


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

Upcoming Class

-1 day 24 Sep 2021


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

Upcoming Class

-1 day 24 Sep 2021

Business Analyst

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

Upcoming Class

-1 day 24 Sep 2021

MS SQL Server

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

Upcoming Class

0 day 25 Sep 2021


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

Upcoming Class

0 day 25 Sep 2021

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks

Upcoming Class

0 day 25 Sep 2021

Machine Learning

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

Upcoming Class

13 days 08 Oct 2021


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

Upcoming Class

-1 day 24 Sep 2021

Search Posts


Receive Latest Materials and Offers on Java Course