in Articles

Reasons Why I Use JQuery Framework

A couple of years ago it looked like javascript was a dead language, it was slow, it was hard to debug and it was inconsistent on the different browsers. But then the saviour of JavaScript came along in the shape of jQuery. jQuery is a just a framework which uses JavaScript, but as it is a framework it will make the changes to your code so that everything you write will stay the same on all browsers. Great no longer do we need to use those if statements for if firefox then do this, if IE6 then do this, if IE7 then do this, jQuery will take care of it for you. Nowadays JavaScript is stronger than ever, new browsers are coming out with increase JavaScript engines so now we can generate some very impressive things with this language. Anything you can think of you can make. With the increased ease of animation we now use JavaScript to make some nice slideshow containers or sliding navigation.

Why Use jQuery?

Now there are many JavaScript frameworks out there such as MooTools, DoJo, Prototype and jQuery. So why jQuery? Why use this over the others? There are many reason why to use jQuery...the main reason will always come down to personal opinion. But for me I use jQuery for the ease of programming, it's lightweight, performance is excellent and the amount of inbuilt features is massive. ## Separate JavaScript And HTML

The way you use jQuery is to put everything in a function, everything should use the $(document).ready function.

//Enter jquery code here

The best example to show how it will separate up the script to the HTML is take look at the JavaScript onclick event. This will be placed on a HTML element but it has to be made in the markup.

<a href="#" onclick="runcode()">Run Code</a>

But using jQuery this click event is moved from the markup and into the JavaScript file in the document.ready function.


//run code



One the worst things about picking up a new concept is to get to grips of how to use it. JQuery has very good documentation and a very good jQuery website which explains every function in the framework. The documentation is so easy to follow and understand and there are examples of all functions you just have to use their own website to find out everything you need know. ## JQuery Has An Active Community

The web community is very important to the progress of any product and jQuery community is very active. Having an active community means that there are frequent updates of the framework. Any bugs found can be easily reported to the developers and they will work to fix these as soon as possible. When they are released the community helps spread the word for everyone to update there own jQuery library. ## Lightweight Framework

The problem with using a JavaScript framework is that you need to load in the core files on any page you want to use them on. Loading JavaScript files can affect the speed your page is loaded. JQuery is an extremely lightweight framework the min core files comes to about 20kb which nowadays is nothing in JavaScript. ## JQuery Plugins

You have the ability to move any common bits of code or modules of code into plugins. So if you create a function which you use every time when you make up a new navigation bar or image slider you can remove these functions and replace this with a jQuery plugin. The advantage of using a plugin is that you can easily move this functionality to your different sites and normally just need one line to implement this functionality. The community have created a large amount of plugins which most of them are free and will give you lots of functionality to quickly put into your own sites. ## Chaining Code

One benefit to jQuery is a coding method called chaining, which basically means adding a sequence of functions to a jQuery object. This can be hard to read if you are now used to this language but after using it means it will greatly reduce the amount of code you have to write. For example if you want to remove a class, add a class and change the text of an element then you will have to do something like this.



$('<div>').text('Add Text');

But chaining will allow you to take these three lines of code and combine them into one line.

$('<div>').removeClass().addClass('class').text('Add Text');

These are some of the key reason why I use jQuery framework and will continue to use it.

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email