Tuesday, December 08, 2009

jQuery and JavaScript: A journey across the boundries

Up until recently I have taken the far side of JavaScript and avoided anything to do with the jQuery. I felt that it took that heart and soul from Javascript, turning Nothing could convince me that jQuery was better then JavaScript. As one would say: "I have seen the light!" and it is controllable.

Many of the tedious tasks with JavaScript are handled nicely with jQuery. But don't get too use to using it. I still feel that pure JavaScript is better over jQuery in some cases. I will leave you with a few things to think about as I prepare my next entry.

Adding user defined objects to your page.

This is where I feel you need to stick with JavaScript. Do not add your objects to jQuery unless your extending jQuery. If your creating an object to store the definitions of a cube. It should be done with JavaScript enclosure techniques. If your extending a method in jQuery to help handle your object in the jquery.ui.accordian resources. Do it in jQuery.

Code JavaScript following a coding best practice.

I will be posting later about coding best practices just as everyone else has. I will compare techniques so that you can choose which path. Though in some cases there is only a single path that you should ever consider. No one way is right.

Code with a purpose.

Don't load up you JavaScript with too many objects that are never used. I have seen too many sites that load 10-20 scripts of jQuery and proprietary code, then never use it. Though I may have not needed to wait for all those files to download, I still had to have that traffic. It's pointless to load that much. Only load what you need right now and progressively load anything you need in the future.

Have fun but don't break anything.

If you use someone else's library don't rewrite it. Extend it. I work with people who think, oh this function is so horrible that I will be better off rewriting it. DON'T. Create a new function and extend that functionality with your own file. jQuery is built so you can extend, you don't have to rewrite it. The next person to work with your code will break everything when they update the jQuery file. Play it safe. Code Smart.

No comments:

Ajax Lesson

NOTE : This lesson uses jQuery as the interface for basic AJAX work. By no means is AJAX a product of jQuery and you do not need jQuery to ...