Category Archives: JavaScript/jQuery

I am JavaScript fanboy

Evangelizing jQuery

Regular readers of this blog will know that I am great fan of jQuery. Recently I am thinking of evangelizing jQuery at work and convince people who take up decision to make jQuery as the default JavaScript framework to be used across the organization.

The following is the list of advantages/benefits which I have prepared so far. 

  • Light weight and has a very small footprint.
  • Browser abstraction – jQuery provides browser abstraction and is hightly optimized for each individual browser.
  • Excellent Plugin architecture – jQuery has an excellent Plugin architecture and you can find a jQuery Plugin for anything that you want to do.
  • Speed – When compared with other libraries, jQuery is much faster.
  • Less code == Less mistakes == better performance.
  • Active development community – It has a very active development community headed by John Resig
  • Backed by major organizations like Microsoft and Nokia. Microsoft had integrated it with the latest version of ASP.NET
  • Very small learning curve.
  • Chaining well suited for designers since it uses selectors based on CSS Selectors.
  • Excellent Documentation for all methods and selectors.
  • jQuery UI – Provides ready made themable GUI components.

Let me know if you could think of any addition to this list. Thanks 🙂

Posted in JavaScript/jQuery | Tagged , | 8 Comments

Notes for “DOM is a mess” by John Resig

I just finished viewing John Resig’s talk titled “DOM is a mess” at Yahoo. I took some notes while watching the video and I am posting them here, so that I can refer to them at a later point of time (It is easier to search when it is not on paper 🙂 ). Also it might help someone to get the outline of the talk before actually watching the video. The original video runs for more than an hour.

Also be warned that the following is my own interpretation of the video and I might have missed or could have interpreted some point differently. 🙂

About the speaker, John Resig

As you all know John Resig is the creator of the excellent jQuery library. He works for Mozilla corporation and you can get more information about him from his blog.

DOM is a mess

This is the first thing John Resig said about DOM methods after saying that DOM is a messy

Nearly every DOM method is broken in some way, in some browser.

The following are some of the bugs in the DOM methods

getElementByID ()

IE and Old versions of Opera return elements whose name == id

getElementByTagName ()

.length gets overwritten in IE if an element with an ID = “length” is found

getElementsByClassName ()

Opera doesn’t match a second specified class

querySelectorAll ()

Safari 3.2 can’t match uppercase characters in quirks mode.

So the moral is that almost every method in DOM is messed up.

Writing Cross-browser code

Find out the cost/benefit ratio for supporting a browser and then pick the browsers you are going to support before writing your code.

He talked about Yahoo’s graded support and jQuery browser Support.

Escaping from DOM’s mess

The following are some of the tips to escape from DOM’s mess.

  • Having a good test suite is not a facility but a requirement.
  • Don’t introduce global variables or extend native objects.
  • The order in which style sheets are included matters.
  • Don’t use browser sniffing, but use Object detection or feature simulation instead.
  • Don’t assume a browser will always have a bug. They might get fixed in a future release.
  • Gracefully degrade for old browsers
  • As your code matures, the number of assumptions should reduce.
  • While removing elements from DOM, clean it by unbinding the events

Links

So my dear readers what you think about my notes. Also let me know if you like notes for videos in this format. If there is a demand, then I can post some of my notes on other videos which I have already viewed.

Posted in JavaScript/jQuery | Tagged , , , , , | 1 Comment

Two more reasons to like jQuery

Out of the numerous JavaScript libraries which are available, jQuery is my favourite. There are couple of reasons for this and now I have two more reasons added to that list. 

First jQuery is going to be supported by Microsoft and is going to be shipped with Visual Studio, which is great news for people who are addicted to intellisense (like Yuvi 😉 ). 

Second Nokia is going to support it and jQuery will be used to develop applications on the new WebKit-based Web Run-Time which will be distributed with Nokia phones.

I think this is great news for jQuery and it is time for me to start hacking it again. 😉

Posted in JavaScript/jQuery | Tagged , , | Leave a comment

Useful jQuery links

I found a lot of useful links related to jQuery while researching for my presentation on jQuery. I thought of sharing them here so that it will be useful for others who are looking to get their feet wet with jQuery.

I am planning to constantly updated this post, so if you have any other links which might be useful do leave a comment and I will add them.

Homepage

References

Tutorial/Articles

jQuery related slides

Some useful Plugins

jQuery Related Books

Posted in JavaScript/jQuery | Tagged , , | 4 Comments

Why no AJAX?

I was viewing the score for the cricket match between India and England from Yahoo! India Cricket portal. The problem being a web programmer is that you always tend to look at each web page from the development perspective and something grabbed my attention. The web page was refreshing every 60 seconds to get the latest score and a new request/response is generated every time. (Ok so have you got what I was thinking about?) Why are they not using AJAX to refresh the scores rather than refreshing the whole page every time?

The web developer inside me got out and I immediately checked the other sites which are also offering the cricket scores. I checked Sify and Rediff. Even they are not using AJAX and are refreshing the whole page every time. But the refreshing interval was different. Here is the refreshing interval which I got by looking at their META tag.

Rediff 480 seconds
Yahoo India 60 seconds
Sify 60 seconds

The obvious advantage in using the AJAX approach (XMLHTTP) is that the amount of data that is going to get transferred from the server is going to be less and it’s going to save the bandwidth by leaps and bounds.

I would be really happy if any one from either Sify or Rediff or Yahoo! India reads this and just gives a thought about it. And do any of you guys know how to get the raw data about the scores and the license requirement (if available). I am thinking of giving it a try and build a POC (Proof of Concept) app, if the data is available.

Oops!, by the time I could compose this post, the match has been stopped due to rain 🙁

Posted in JavaScript/jQuery | Tagged , , , , , , | 6 Comments

Happy Birthday, AJAX

Well it’s being one year since Jesse James wrote his (in)famous article and coined the term AJAX.

This particular buzzword (and technology) has taken web development world by storm and within just one year the usability that you can expect from a web site has increased by leaps and bounds.

Happy birthday, AJAX and hoping for more from you this year too.

Posted in JavaScript/jQuery | Tagged , , | 3 Comments

AJAX Library

Regular readers of my blog would have noticed that off late, I am not updating the blog much. The reason for that is, first work is taking most of my time, second I am working on a small pet project, more on it later 😉 so as to get my hands dirty with AJAX.

I was googling around to find out a good library for AJAX, so that I can start with it. And I came across Backbase. It looked very promising, so I downloaded the community edition and started working with it. But I felt it is very complex and I am not sure whether it is worth the effort and moreover I am worried about the lincening too.

So people I need some help from you. Can you suggest/recommend or point me to some good library for implementing AJAX into web applications. I am particularly interested in libraries which work (at least decently) across platforms. So guys I am waiting for your replies.

PS: I have already written a small wrapper function for XMLHttp object, which works in the latest version of both IE and Firefox. I will post it once I finish testing it. Meanwhile if any of you want to have a look at it, just leave a comment or mail me.

Posted in JavaScript/jQuery | Tagged , , | 5 Comments

JavaScript Components

Check out yxScripts.com. Excellent ready to use java script components like Menu, calendar etc.. Really damn good.

Posted in JavaScript/jQuery | Tagged | Leave a comment

Client-side DateAdd function

I was Googling around to find out how to hadle date addtion in Javascript and then found the following DataAdd funtion. Very useful. Check it out yourself

A better client-side DateAdd function.

Posted in JavaScript/jQuery | Tagged , | Leave a comment

JavaScript Toolbox

JavaScript Toolbox – Reusable Libraries And Objects

This is a collection of Javascript source files, examples, and concepts. Use these instead of always re-inventing JavaScript solutions.

Posted in JavaScript/jQuery | Tagged , | Leave a comment