jQuery Samples (Maybe) for SonghaySystem.com

Buy this Book at Amazon.com!A new /jquery folder is added to the dev’ server samples folder. The work here is intended to replace the older samples in the /DHTML and /ajax folders. Today, the plan is to use jQuery exclusively. This decision is based on the following:

  • My current understanding of the YUI 3.0 Loader shows me not an equivalent of jQuery.getScript() but far more complex functionality that seems to focus on loading YUI modules more than plain-old *.js files. This script loading issue is important—this is why projects like Jingo exist.
  • The CSS-selector syntax in YUI 3.0 is there but I do not feel the terseness that’s attractive in jQuery. The code samples seem noisy to me. This pressure to rewrite my YUI 2.x code in this “new” style might as well be relieved in jQuery.
  • The advantages that might be clear and present in YUI over jQuery do not appeal to me. An article like “Why YUI is my favorite JavaScript framework and why it should be yours too!” sites advantages like “Debugging and Profiling” or “Blistering fast framework hosting and serving of assets”—I would like to have these problems and I look forward having them. By the time I get there, jQuery should have already been and moved on…

Today, my only pressing question about jQuery is about the when to use jQuery.extend() and, jQuery.fn (which is used for plug-ins). Basil Goldman seems to have an explanation in “Defining your own functions in jQuery” but for some reason I’m still not satisfied that I have the best information. Once we start to work with jQuery.fn we must consider whether we should just build a full-blown plug-in. This implies three issues: extending, adding a new function and building a plug-in. There should be an explanation that coheres all three.

jQuery: $.extend() and $.fn.extend() confusion “As a general rule, you should extend the jQuery object for functions and the jQuery.fn object for methods. A function, as opposed to a method, is not accessed directly from the DOM.”
jQuery extend and fn.extend “Use the extend function to add a new function to a jQuery object. … Use the fn.extend function to add a new function that will be applied to each element in the set of elements in a jQuery object.”
Learn How To Create Your Own jQuery Plugin “The basis of creating a plugin for jQuery is actually quite simple. You don’t have to be a jQuery ninja, nor do you have to sweat blood to make it work. It’s as easy as script writing!”
A Plugin Development Pattern “In Mike Alsup’s preamble, I’m inferring that a formal plug-in is needed when your extension depends on one or more ‘private’ functions.”