jQuery interview questions and answers – Part2

11. Why should you use jQuery?
“To make web pages better” is the right answer, but your interviewer is probably looking at something more nuanced like a list of key jQuery features and advantages, such as:
• jQuery simplifies client-side scripting (read: front-end development) without adding to page bloat.
• jQuery is easy to use; it is possible to include advanced jQuery features without knowing how to code thanks to countless existing plugins.
• Widespread community support. It is also supported by most major platforms.
• Free, open-source. jQuery is released under the flexible MIT License.
• Built-in AJAX capabilities, creating animations, applying CSS and event detection.
• Supported across virtually all modern browsers.
It helps to
• Improve the performance of the application
• Develop most browser compatible web page
• Implement UI related critical functionality without writing hundreds of lines of codes
• Fast
• Extensible – jQuery can be extended to implement customized behavior
Other advantages of jQuery are
• No need to learn fresh new syntax’s to use jQuery, knowing simple JavaScript syntax is enough
• Simple and Cleaner code, no need to write several lines of codes to achieve complex functionality.
• Used to develop browser compatible web applications
• Improve the performance of an application
• Very fast and extensible
• UI related functions are written in minimal lines of codes

12. What are the differences between jQuery and JavaScript?
JavaScript is a language. jQuery is a library/framework built using JavaScript.

13. What do you need to start using jQuery?
Simple: a reference to the jQuery library. The best way to do this is to add a link toGoogle’s jQuery developer library in your <head> or before the </body> tag*. This makes sure that you always have the latest version of the jQuery library, and also helps improve page speed.
*Including references to JavaScript/jQuery in the <head> can reduce page load speed (as it forces the browser to load the JS before loading the actual page elements). For performance purposes, it is better to include the link before </body>.

14. What are the advantages of using jQuery?
• It has AJAX capabilities
• Easy to learn, use and expand
• Great built-in methods
• From the definition, it is cross-browser.
• Makes DOM Manipulation and Traversal easier.
• It is more like a JavaScript enhancement so there is no overhead in learning a new syntax.
• It has the ability to keep the code simple, readable, clear and reusable.
• It would eradicate the requirement for writing complex loops and DOM scripting library calls.
• One can easily provide effects and can do animations.
• Applying / Changing CSS.
• Cool plugins.
• Ajax support
• DOM selection events
• Event Handling

15. Is jQuery a client-scripting or server-scripting library?
jQuery is used for client-scripting.

16. Can you use other client-scripting libraries alongside jQuery?
Yes you can. You can achieve this by using jQuery.noConflict() function to avoid any conflicts resulting from the use of $() by other libraries.

17. What is a Content Delivery Network (CDN)?
A large distributed system of servers deployed in different data centers across the internet. Normally intended to serve content to end-users with high availability and performance.

18. How to load jQuery from CDN?
Below is the code to load jQuery from all 3 CDNs.
Code to load jQuery Framework from Google CDN

<script type="text/javascript"

Code to load jQuery Framework from Microsoft CDN

<script type="text/javascript"

Code to load jQuery Framework from jQuery Site(EdgeCast CDN)

<script type="text/javascript"

19. How to load jQuery locally when CDN fails?
It is a good approach to always use CDN but sometimes what if the CDN is down (rare possibility though) but you never know in this world as anything can happen.
Below given jQuery code checks whether jQuery is loaded from Google CDN or not, if not then it references the jQuery.js file from your folder.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
document.write(unescape("%3Cscript src='Scripts/jquery.1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));

It first loads the jQuery from Google CDN and then check the jQuery object. If jQuery is not loaded successfully then it will references the jQuery.js file from hard drive location. In this example, the jQuery.js is loaded from Scripts folder.

20. Which are the popular jQuery CDN? and what is the advantage of using CDN?
There are 3 popular jQuery CDNs.
1. 1. Google.
2. 2. Microsoft
3. 3. jQuery.
Advantage of using CDN:
• It reduces the load from your server.
• It saves bandwidth. jQuery framework will load faster from these CDN.
• The most important benefit is it will be cached, if the user has visited any site which is using jQuery framework from any of these CDN

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

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

seven + 6 =

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter