ColdFusioning: Pronunciation \kold-fy�-zhn-ing\ Noun: The action of one that writes ColdFusion.

jQuery Document Ready Shortcut

Here's a quick tip. Instead of writing:


$(document).ready(function() {
// Code and functions here
});

We can instead write:

$().ready(function() {
// Code and functions here
});

or even:

$(function() {
// Code and functions here
});

Albeit, it isn't a huge code reduction but it is a nice shortcut.



Comments
Scott Stroz's Gravatar I like that we can use these shortcuts in jQuery, however, I am hesitant to use them. Why? Well, because I think the original way is easier for someone not well versed in jQuery to figure out what is going on.

We never know who will need to work on our code and I strive to make sure that my code is easy to understand and 'figure out' even if you do not know exactly what is going on.
# Posted By Scott Stroz | 10/26/09 10:02 AM
Raymond Camden's Gravatar I'm in the same boat as Scott - those shortcuts are -real- weird if you are a newbie. :)
# Posted By Raymond Camden | 10/26/09 11:28 AM
James Brown's Gravatar Would you both advocate not using them at all or maybe put a comment before the first one to explain and educate the user?
# Posted By James Brown | 10/26/09 11:38 AM
Raymond Camden's Gravatar Oh I wouldn't advocate against it- I just wouldn't use it -myself-. And in a team environment I'd be cognizant of the skill levels of the other team members.

Nothing more than that really.
# Posted By Raymond Camden | 10/26/09 11:40 AM