Why Jquery?: Vishwak Lab'S White Paper
Why Jquery?: Vishwak Lab'S White Paper
Contents
Purpose of this document ............................................................................................................................. 3 Why use JQuery ............................................................................................................................................ 4 What you can get from JQuery ..................................................................................................................... 5 DOM element selector .............................................................................................................................. 5 Wrapped set operations ........................................................................................................................... 5 Event Handling in JQuery .......................................................................................................................... 5 Easy plug-ins.............................................................................................................................................. 5 JQuery with ASP.NET..................................................................................................................................... 6 JQuery with other libraries ........................................................................................................................... 7 Plug-ins and authorizations .......................................................................................................................... 8 Conclusion ..................................................................................................................................................... 8 References .................................................................................................................................................... 9 About the Author .......................................................................................................................................... 9 About Vishwak .............................................................................................................................................. 9
Disclaimer: These evaluations are purely the opinion of the author(s) of this article based on their observations during the evaluation of the JQuery; Vishwak doesn't necessarily endorse any of these observations. This article is shared purely as a knowledge sharing initiative for the general audience.
It has small library with Document Object Model (DOM), Quick access to AJAX, without a lot of bloat and some basic animations. The basic JQuery is just 15K and JQuery holds a strong and flexible mechanism for adding methods and functionalities which bundled as plug-ins. It supports CSS 1-3 and basic X-Path; works with Firefox 1+, Internet explorer 5.5+, Safari 1.3+ and Opera 8.5+.
Before we get into samples, there is one basic and simple JQuery library which is .Ready(). Everything in the JQuery utility is HTML and DOM. So to process this, the document should be loaded before we use JQuery features. This can be done using ready event. Ready is the first event fired once the document loaded.
$(document).ready(function() { // Your code goes here });
It elegantly finds and manipulates HTML elements using very nice selector API which allows any JQuerian to query for HTML elements and then apply commands to them. It can be chained very easily so that the result of one command can feed into another. For example, the sample one line code finds all <div> elements within the page which has a CSS class as slide and then animate it to slowly disappear. $(div.slide).slideup(slow).addClass(removed); thats how easy it is.
Easy plug-ins
JQuery is a language with DOM extension library with tight focus on core functionality. For everything else JQuery provides an easy plug-in API for almost all operations you can do with DOM operations.
Why JQuery & Not JavaScript JQuery API allows extending the core JQuery object operations simply by creating a function and passing parameter to JQuery wrapped set. Using this method allows you to use the plug-ins which will receive a wrapped set and can operate and participate in JQuery chaining. If no plug-ins wont satisfy your requirement, you can write your own plug-in which gives you more comfort. This simple and powerful plug-in model is easy to learn and work.
Or there is also another option to make sure it wont conflict with another library, you have something like example here where j has been added along with $
<html> <head> <script src="prototype.js"></script> <script src="jquery.js"></script> <script> var $j = jQuery.noConflict(); // Use jQuery via $j(...) $j(document).ready(function() { $j("div").hide(); }); // Use Prototype with $(...), $('HTMLid').hide(); </script> </head> <body></body> </html>
Why JQuery & Not JavaScript If you include JQuery before libraries, you can use JQuery instead of $ and you can use other library like prototype with $ without any conflict. You can also assign JQuery to a variable, or to a function like (function ($) , /* your code */- ) (JQuery) . The only downside of using function is you cant use the prototype methods. When compared to other libraries, the usage of JQuery libraries and its functions is efficient and it will not conflict with other libraries you are using. The option of using multiple libraries without any conflict is handled very efficiently in JQuery.
Conclusion
Though everything looks good in JQuery, there are some downsides like - number formatting, date formatting and window support along with other native JavaScript support. It is not a perfect tool to solve your entire problem with JavaScript and DOM problems you are facing. Butwe am sure; it will not give you any showstoppers. For non-DOM related functionalities you might need to write some helper functions to support. Another issue we see is versioning and possible interference with other libraries which uses $ like Prototype which has many similar functionality like JQuery. But Prototype is not backed with CSS and XPath selectors and with the ability to chain methods to do interesting functionalities in concise manner. If you use the library as downloadable, then you will end up in renaming files and references frequently as and when the library is updated. If you use fixed one then you may end up versioning issues. Our internet search result did not throw-up us any negative feedback and who ever uses it seem to be comfortable. But you can judge for yourself.
References
1. You can find some JQuery help controls in the below links: http://www.west-wind.com/tools/westwindajaxtoolkit/docs/?page=_2hh0s4zli.htm 2. Also you can find more documents and help in: http://www.JQuery.com 3. Nice example on all JQuery methods in XML format: http://jquery.com/api/data/jquery-docs-xml.xml 4. JQuery with .NET http://weblogs.asp.net/bleroy/archive/2008/09/28/jquery-now-officially-part-of-the-netdeveloper-s-toolbox.aspx 5. JQuery intellisense in VS.NET 2008: http://blogs.ipona.com/james/archive/2008/02/15/JQuery-IntelliSense-in-Visual-Studio2008.aspx 6. Integrating Sharpoint and JQuery: http://weblogs.asp.net/jan/archive/2008/11/20/sharepoint-2007-and-jquery-1.aspx 7. You can download JQuery from: http://docs.jquery.com/Downloading_jQuery
About Vishwak
Vishwak Solutions is a Global Innovator in application development and maintenance focusing on sophisticated web portals, mobile portal applications and enterprise solutions. Vishwak as a Microsoft Gold Certified partner a tier one portal solutions company adopts to high class web portals with latest technology like .NET for business logics and XHTML/CSS/JQuery/JS for front end and also pioneer in Mobile Web technologies. With deep domain experience in developing and managing leading Media portals Vishwak brings sophisticated tools to ease your portal development project. Whether you are in Media, Entertainment or Publishing Vishwak brings in world class portal technology and process. In the digital economy this helps you to differentiate, extend your brand value and enhance revenue opportunities. We are always closer to you with offices in Redmond (Washington, USA), London (UK) apart from our global delivery center in Chennai (India)