<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Padolsey&#187; General category &#8211; James Padolsey</title>
	<atom:link href="http://james.padolsey.com/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 21 Aug 2010 04:38:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dear .NET</title>
		<link>http://james.padolsey.com/javascript/dear-net/</link>
		<comments>http://james.padolsey.com/javascript/dear-net/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 00:24:10 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Critical]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1619</guid>
		<description><![CDATA[<em><a href="http://www.netmag.co.uk/">A letter to the .NET magazine</a></em>

Staring keenly at a stack of magazines, I hazard a gaze towards the computer
section and lay my eyes upon the newest cover of my sworn enemy, the .NET
magazine. Its luring front-page convinces me that it deserves my consideration.&#8230;]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://www.netmag.co.uk/">A letter to the .NET magazine</a></em></p>

<p>Staring keenly at a stack of magazines, I hazard a gaze towards the computer
section and lay my eyes upon the newest cover of my sworn enemy, the .NET
magazine. Its luring front-page convinces me that it deserves my consideration.</p>

<p>I buy it without looking inside. I want to reserve the surprise for later.</p>

<p>Now sitting in the lounge at London Gatwick Airport, I whip out the magazine
and rush to a JavaScript article. I can&#8217;t wait. It&#8217;s about jQuery and I just know
that they&#8217;ve gotten their act together since <a href="http://james.padolsey.com/general/a-lack-of-progression-2008/">previous encounters</a>. I&#8217;m sure this
article will contain the best in jQuery techniques and JavaScript best practices.</p>

<p>Well, .NET, now I&#8217;m sitting here with the unfortunate duty to inform you of my
unsurprising disappointment.</p>

<p>The truth is I expected nothing more from you.</p>

<p>Please turn to page 80 of issue 205 and pay special consideration to the
following reservations of mine:</p>

<p>The author doesn&#8217;t mention the possibility nor the applicability of creating a
jQuery plugin instead of the single globally defined function &#8216;drawerToggler&#8217;.
What&#8217;s wrong with this? Well, the function happens to contain functionality that
could be abstracted to deal with arbitrary sets of nodes and is therefore suited
to jQuery&#8217;s plugin mechanism. I would understand if at least a mention surfaced,
but nothing.</p>

<p>This is certainly not the worst of it though.</p>

<p>The function itself:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">function</span> drawerToggler<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    $<span class="br0">&#40;</span><span class="st0">'#theme-drawer'</span><span class="br0">&#41;</span>.<span class="me1">slideToggle</span><span class="br0">&#40;</span><span class="st0">&quot;normal&quot;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="st0">'#theme-drawer'</span><span class="br0">&#41;</span>.<span class="kw1">is</span><span class="br0">&#40;</span><span class="st0">&quot;:visible&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
            $<span class="br0">&#40;</span><span class="st0">'#wrapper'</span><span class="br0">&#41;</span>.<span class="me1">css</span><span class="br0">&#40;</span><span class="st0">&quot;margin-bottom&quot;</span><span class="sy0">,</span> <span class="st0">&quot;150px&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
            $<span class="br0">&#40;</span><span class="st0">'#wrapper'</span><span class="br0">&#41;</span>.<span class="me1">css</span><span class="br0">&#40;</span><span class="st0">&quot;margin-bottom&quot;</span><span class="sy0">,</span> <span class="st0">&quot;20px&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>




<p>Where it&#8217;s being called:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
    $<span class="br0">&#40;</span><span class="st0">'.drawer-toggler'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
        drawerToggler<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>This function is called within the click event handler for any element with a
className containing <code>drawer-toggler</code>. Since it&#8217;s getting called on every click,
and the elements selected within the <code>drawerToggler</code> do not change between calls,
it would be logical to select and &#8220;cache&#8221; the DOM object references beforehand,
and then the function could use these DOM references instead of continually
(and redundantly) re-querying the DOM on every single call!</p>

<p>The function itself contains some redundant code too. The &#8216;theme-wrapper&#8217; to
which the <code>slideToggle</code> method is applied, is then re-queried within the callback.
Apparently unbeknown to the author, this very element can be accessed via the
&#8216;this&#8217; keyword within the callback function &#8212; there is absolutely no need to
re-query the DOM for <code>#theme-wrapper</code>!</p>

<p>This isn&#8217;t just a case of my preferences versus the author. There are established
best practices in the jQuery community and as one of the industry&#8217;s top
publications you should be providing not only good advice but near enough the
best advice according to current industry practices and standards.</p>

<span id="more-1619"></span>

<p>Now, I could stop, but the reign of nonsensical JavaScript programming continues.</p>

<p>On page 82, along with the insistence of using <code>$(this).attr('rel')</code> instead of
the terser and faster DOM equivalent, <code>this.rel</code>, the author insists, again,
on re-querying the DOM for unchanged elements within the click event handler for
all anchor elements within <code>#themes-wrapper</code>!</p>

<p>There&#8217;s a few more specific issues I&#8217;d like to raise but I feel I&#8217;ve already made my point in regards to the obvious inadequacy of the article itself.</p>

<p>The article specifically says that it&#8217;s geared towards developers with an
<em>intermediate-level</em> understanding of HTML, CSS and JavaScript. If you want to
further the knowledge and understanding of these developers then you must, as
reason would dictate, have a teacher that presents a <em>higher-than-intermediate</em>
understanding of these technologies.</p>

<p>Before you suggest that I write an article to amend previously made mistakes (<em>&#8220;Instead of complaining write your own article.. blah blah blah&#8221;</em>) I&#8217;d
like to let you know that I will do no such thing. It is your responsibility to
find the best authors and the best content featuring the topic at hand.</p>

<p>I write
this letter not only because I care, but because I am desperately worried, as
are many others, about the state of jQuery within the JavaScript community, and
more generally the lacking understanding that is slowly rotting the core principles of
JavaScript from under its feet. Let the ignorance stain the ranks of beginners
and hobbyists, as it always has and always will, but let it not protrude into a publication that claims to
encapsulate the ever-changing essence of the web industry. Stop pandering to
the lowest common denominator and be the best!</p>

<p>I realise that, from a
monetary perspective, such concerns are likely to be lower on your priority
list than getting that new coffee machine for your staff, but for the love of
what you claim to stand for, prove to me that you are more than what I dare think
you may just be &#8212; another profit-based publication whose sole concern is the
quantity of its readership rather than the quality of its content.</p>

<p>If you&#8217;re going to publish articles relating to JavaScript then you&#8217;re going to
have to tighten your belt and get to work. It&#8217;s not a playground. Currently,
you&#8217;re only serving as a catalyst to the ignorance that a magazine such as
yours should be out to destroy.</p>

<p>If you think this letter is not worthy of your consideration, then discard it as one of many (no doubt) complaints, for I am only too happy to accept that I&#8217;m right about you!</p>

<p>Prove me wrong. I dare you.</p> 

<p><em>JAMES PADOLSEY</em></p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/javascript/dear-net/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Me&#8230;</title>
		<link>http://james.padolsey.com/general/me/</link>
		<comments>http://james.padolsey.com/general/me/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 17:24:12 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Me]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1613</guid>
		<description><![CDATA[Okay. For once, I&#8217;m going to say what I actually think on this site of mine! I&#8217;ve done it to a degree before but I got frequently hushed by the few people that see anything but neutrality as a weakness or a threat. I&#8217;m only&#8230;]]></description>
			<content:encoded><![CDATA[<p>Okay. For once, I&#8217;m going to say what I actually think on this site of mine! I&#8217;ve done it to a degree before but I got frequently hushed by the few people that see anything but neutrality as a weakness or a threat. I&#8217;m only human, and I have some damned opinions. So here they are!</p>

<p><em>Be prepared for mildly offensive rhetoric and inappropriate usage of the ellipsis and exclamation mark!!!</em></p>

<ul>
    <li>
        <p>I think this universe is simply awesome. We&#8217;re quite tiny when everything is put into perspective. Heck, we&#8217;re just one form of life, on one planet, in one star system of hundreds of billions of star systems in this galaxy alone (which itself is accompanied by hundreds of billions of other galaxies), and yet some people still have the arrogance to feel that the human race is at the centre of the whole universe! Our wonderful yet miniscule existence is aptly covered in this <a href="http://www.youtube.com/watch?v=p86BPM1GV8M">beautifully poetic video</a> from the late Carl Sagan.</p>
    </li>
    <li>I think inline documentation, like that made possible with JSDoc, makes code ugly and unreadable. I want to see the code, and that&#8217;s all!</li>
    <li>I love the outdoors. I envy people that have jobs outside. And I don&#8217;t mean outside on the street cleaning up human sewage. I mean outside in the real world &#8212; the places that we haven&#8217;t yet destroyed.</li>
    <li>I think heavy UI abstractions like ExtJS totally take away all of the fun, excitement and challenges that should form a central part in any programmer&#8217;s role. To me, it looks like a product built for business people, and business people rarely understand the motives and desires of programmers &#8212; they only understand a couple of things: profit margins and economic viability.</li>
    <li>I&#8217;ve yet to sit in an office chair that won&#8217;t make my back hurt like hell after eight hours.</li>
    <li>I don&#8217;t believe in a God. I also don&#8217;t believe in fairies or unicorns.</li>
    <li>I get annoyed when people don&#8217;t realise the difference between believing that something doesn&#8217;t exist and rejecting the belief that something does exist, for it should be apparent that there is a huge difference.</li>
    <li>My favourite comedians of all time are <a href="http://www.youtube.com/watch?v=hYytaZ06Hco">Ricky Gervais</a>, <a href="http://www.youtube.com/watch?v=MvgN5gCuLac">George Carlin</a>, <a href="http://www.youtube.com/watch?v=QvOQxeQKrdw">Frankie Boyle</a> and <a href="http://www.youtube.com/watch?v=Q95kX_EP2Nk">Bill Hicks</a> (watch all the videos!).</li>
    <li>I hate running, but I absolutely love cycling!</li>
    <li>I don&#8217;t understand Node.js. I really did try, but it just ended up confusing me. I&#8217;m not a Linux wizz so installing it was trouble enough.</li>
    <li>I think modern day advertising and marketing techniques are the bane of western society. Oh, and politicians!</li>
    <li>I didn&#8217;t care for the World Cup, and I always find it amusing how people shout at the TV and put flags on their cars when it won&#8217;t have the slightest effect on the game itself.</li>
    <li>I&#8217;m trying to become a vegetarian. Watch the documentary, <a href="http://www.earthlings.com/">Earthlings</a>, and you&#8217;ll understand why.</li>
    <li>Pixar <a href="http://www.imdb.com/title/tt0435761/">made me cry</a>. I don&#8217;t know how they did it&#8230;</li>
    <li>I&#8217;d love to know how to play a musical instrument properly. Preferably the piano.</li>
    <li>I think humans have a responsibility to stop using non-renewable resources, but I don&#8217;t think playing the blame-game is helpful. I also don&#8217;t think change will happen given the current political and economic powers that be.</li>
    <li>I have a love-hate relationship with PHP. Doing most things is dead simple (which is great), but it&#8217;s such an ugly language!</li>
    <li>Even after all this time, jQuery is still my favourite JavaScript library. It&#8217;s small, intuitive and doesn&#8217;t require me to adopt a new programming paradigm!</li>
    <li>Other movies that have made me weep like a baby include <a href="http://www.imdb.com/title/tt1277737/">The Stoning of Soraya M</a>, <a href="http://www.imdb.com/title/tt0109830/">Forrest Gump</a>, <a href="http://www.imdb.com/title/tt0078950/">The Champ</a> and <a href="http://www.imdb.com/title/tt0223897/">Pay It Forward</a>.</li>
</ul>

<p>Okay, that&#8217;s enough for today. Comment if you want. If you disagree with me on any of these points, then, GOOD! This world would be such a dull place without such varied opinions and people!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/general/me/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Questioning non UI events</title>
		<link>http://james.padolsey.com/javascript/questioning-non-ui-events/</link>
		<comments>http://james.padolsey.com/javascript/questioning-non-ui-events/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 06:22:31 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1573</guid>
		<description><![CDATA[Without UI events we&#8217;d be totally lost on the client-side &#8212; it is only via User Interface Events that we can know what the user wants to do. User-initiated events such as &#8220;click&#8221;, &#8220;mouseover&#8221; and &#8220;mousemove&#8221; are absolutely essential to upholding a user-centred experience and&#8230;]]></description>
			<content:encoded><![CDATA[<p>Without UI events we&#8217;d be totally lost on the client-side &#8212; it is only via User Interface Events that we can know what the user wants to do. User-initiated events such as &#8220;click&#8221;, &#8220;mouseover&#8221; and &#8220;mousemove&#8221; are absolutely essential to upholding a user-centred experience and I want to make it clear that my quarrel is not with these types of events. Any event that gives us information about users&#8217; intentions is a good event.</p>

<p>I feel that there are bad events too though &#8212; events that we feel we must utilise just because they exist &#8212; and we feel we must build into our APIs just because event-driven design dictates absolute submission to this way of thinking.</p>

<h3>DOM mutation events</h3>

<p>Every single time I&#8217;ve ever considered using a DOM-mutation event I&#8217;ve subsequently discovered that the problem can be better solved by re-architecting the codebase. The <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents">DOM2 mutation events</a> aren&#8217;t well supported in less capable browsers but offer an interesting opportunity &#8212; to listen for document mutation such as attribute changes, node insertion and node removal.</p>

<p>This sounds cool and I&#8217;m sure your mind was buzzing with ideas when you first heard about these events, but have you actually encountered a situation where utilising these events is the only viable solution? If so, I&#8217;d love to hear it.</p>

<span id="more-1573"></span>

<h3>Programmatic events</h3>

<p>This is where I lose all sense of comprehension. The premise is a mechanism that allows you to be notified when changes occur to your program &#8212; i.e. your objects, arrays and functions. I&#8217;m talking about the likes of <code>Object.prototype.watch</code>, IE&#8217;s <code>onPropertyChange</code> and a tonne of other new implementations (<a href="http://wiki.github.com/nje/jquery-datalink/jquery-data-linking-proposal#arraychange">e.g.</a>) that seem to perpetuate a dangerous disconnect of cogs that should be working together.</p>

<p>It seems pointless &#8212; it&#8217;s akin to starting your car, and then being notified by the car that you just started the car&#8230; an entirely redundant notification.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> a <span class="sy0">=</span> abstraction.<span class="me1">Array</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">2</span><span class="sy0">,</span><span class="nu0">3</span><span class="br0">&#41;</span><span class="sy0">;</span>
a.<span class="me1">push</span><span class="br0">&#40;</span><span class="nu0">4</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="co1">// &gt; Abstraction says: &quot;You just changed the array&quot;</span>
<span class="co1">// &gt; Me says: &quot;OH RLY&quot;</span></pre></div></div>




<h3>Left hand, meet right hand!</h3>

<p>Events exist so that processes outside the scope of your code can communicate with your code and let you know when certain things occur. Events typically operate up the abstraction chain &#8212; you listen for events from lower-level abstractions. I feel that the &#8220;outside the scope of your code&#8221; aspect is central to the whole concept of events and is why they make so much sense in a browser-scripting environment. The browser listens to events from the operating system and forwards certain events to the DOM where we can listen for them. It&#8217;s a simple fluid concept that works!</p>

<p>There&#8217;s a lot of hype surrounding event-driven programming/design at the moment and it seems that we&#8217;re approaching a risky threshold, where events are used just because they can be, and not because they <em>should</em> be.</p>

<p>If you&#8217;re creating an app, and it requires a great deal of client-side functionality, then you&#8217;re going to need to interface with the DOM to listen for events and apply certain changes. This is what JavaScript is all about. You write the logic layer of code (your own personal API) and then you write the implementation code that utilises the logic layer. You have authored two distinct layers of abstraction. That&#8217;s pretty much the gist of what we do.</p>

<p>What&#8217;s approaching, it seems, is an era of haphazard juggling of third-party scripts, multiple abstractions, multiple APIs and consequently, <em>dozens</em> of events. No need to write a consistently encapsulated logic layer &#8212; you can just bung these plugins/modules/classes into the app&#8230; To heck with maintenance, clean and consistent abstractions, intuitive APIs, self-documenting code and all sense of originality.</p>

<p>I&#8217;m not questioning events in general, and I will admit that they can be very helpful to make two scripts work together, but as I mentioned, I feel there&#8217;s a threshold where it becomes simply foolish&#8230;</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/javascript/questioning-non-ui-events/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>jQuery: Novice to Ninja</title>
		<link>http://james.padolsey.com/javascript/jquery-novice-to-ninja/</link>
		<comments>http://james.padolsey.com/javascript/jquery-novice-to-ninja/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 16:17:19 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1442</guid>
		<description><![CDATA[<a href="http://www.sitepoint.com/books/jquery1/">Sitepoint&#8217;s latest title</a> is aimed at the average Front-end developer/designer and promises to teach her the intricate workings of the jQuery library. In fact, if we&#8217;re to go by the title, it promises to take her from &#8220;novice to ninja&#8221;. Let me be honest, I was&#8230;]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sitepoint.com/books/jquery1/">Sitepoint&#8217;s latest title</a> is aimed at the average Front-end developer/designer and promises to teach her the intricate workings of the jQuery library. In fact, if we&#8217;re to go by the title, it promises to take her from &#8220;novice to ninja&#8221;. Let me be honest, I was originally skeptical of the book, but upon finding out that it was co-authored by the esteemed <a href="http://www.mrspeaker.net/">mrspeaker</a> my mind was quickly changed.</p>

<a href="http://www.sitepoint.com/books/jquery1/"><img class="main-img" src="http://james.padolsey.com/wp-content/uploads/jquerysp.jpg" alt="jQuery: Novice to Ninja" /> </a>

<p>As with any good book, the first chapter outlines what the subject matter is. The authors talk about jQuery itself and touch briefly on the DOM. You have to remember that this book is aimed at developers or designers that don&#8217;t really know that much about JavaScript, the DOM, or jQuery, so the book is accordingly written in such a way that it won&#8217;t confuse the pants off your typical photshop-wizz turned HTML/CSS guy.</p>

<p>So if you know JavaScript well, you might not enjoy this book &#8212; it will probably annoy you, simply because it doesn&#8217;t go into a huge amount of detail on what&#8217;s happening behind the scenes. But, for those that it&#8217;s aimed at, I think it does a pretty good job.</p>

<p>One thing that we have a problem with, in the jQuery community bubble, is the overzealous generation of redundant nomenclature. This book doesn&#8217;t fall short on this front. jQuery&#8217;s methods are referred to as &#8220;actions&#8221;.</p>

<p>The second chapter covers the most basic usages of jQuery, <em>selecting</em> stuff and <em>doing</em> stuff. It&#8217;s all innocent and simple &#8212; I like it. To keep the reader focused the authors have slipped in &#8220;A few tricks&#8221;. Among them is the popular add-a-class-on-mouseover, remove-it-on-mouseout. </p>

<p>Nearing the end of chapter two, the book has the following to say about the <code>hover</code> method:</p>

<span id="more-1442"></span>

<blockquote><p>&#8220;It requires two functions as parameters: one to handle the <code>mouseover</code> event, and one to handle the <code>mouseout</code> event.&#8221;</p></blockquote>

<p>The book <em>does</em> claim to be 1.4-ready, so I think it&#8217;s only right to mention this. In jQuery 1.4 the <a href="http://api.jquery.com/hover/">hover method</a> accepts either one or two parameters, and they don&#8217;t correspond to the <code>mouse(over|out)</code> events; they correspond to the <code>mouse(enter|leave)</code> events, although I guess they&#8217;re not totally incorrect on this because jQuery simulates these events using <code>mouse(over|out)</code> in non-supporting browsers, but it is nevertheless an oversight.</p>

<p>Not soon after that did I find what I consider to be a grievous anti-pattern:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">'.spoiler'</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
$<span class="br0">&#40;</span><span class="st0">'&lt;span class=&quot;revealer&quot;&gt;Tell me!&lt;/span&gt;'</span><span class="br0">&#41;</span>
    .<span class="me1">insertBefore</span><span class="br0">&#40;</span><span class="st0">'.spoiler'</span><span class="br0">&#41;</span><span class="sy0">;</span>
$<span class="br0">&#40;</span><span class="st0">'.revealer'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">fadeIn</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>It seems that in their desperation to keep it simple, the authors have chosen to spare the readers of what would be some very good advice. When you add something to the DOM, and it doesn&#8217;t need to be referenced within a CSS StyleSheet, then giving it a class or ID, and then getting a reference to that element via that hook, is normally an almost-entirely redundant process. This would be a far better approach:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> spoilers <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'.spoiler'</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span>
    buttons <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'&lt;span&gt;Tell me!&lt;/span&gt;'</span><span class="br0">&#41;</span>.<span class="me1">insertBefore</span><span class="br0">&#40;</span>spoilers<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
buttons.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">fadeIn</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>Or, even:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">'.spoiler'</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">before</span><span class="br0">&#40;</span>
    $<span class="br0">&#40;</span><span class="st0">'&lt;span/&gt;'</span><span class="sy0">,</span> <span class="br0">&#123;</span>
        text<span class="sy0">:</span> <span class="st0">'Tell me!'</span><span class="sy0">,</span>
        click<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
            $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">fadeIn</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span><span class="br0">&#41;</span>
<span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>If I was the author, I don&#8217;t know what I would have done in this situation&#8230; since it&#8217;s a teaching exercise, do you show the readers how it <em>should</em> be done, or do you show them in the simplest way possible, so as to not bulldoze them with complexities?</p>

<p>Moving on, the book is very <em>cookbook&#8217;y</em> and focuses heavily on an imagined client that has lots of strange requirements (quite typical of your average client). From the introduction to chapter three:</p>

<blockquote><p>&#8220;The client is extremely happy [...] he believes flashy animations will help boost sales.</p>
<p>&#8216;I think it needs some of that Web 2.0 that I&#8217;ve been hearing about,&#8217; he says confidently. &#8216;Can you make it look more like a Web 2.0?&#8217;</p>
<p>&#8216;Errrm, indeed we can,&#8217; you assure him, as he passes you his next wish list chock-full of exciting changes—a list that will allow us to move beyond simply hiding and showing, and closer to our goal of being a jQuery ninja.&#8221;</p></blockquote>

<p>I have a soft spot for these kind of tongue-in-cheek introductions, they&#8217;re quite popular in other programming books too, and I think it does well to mentally elevate the reader &#8212; and to develop that all-important reader-author relationship.</p>

<p>Before you know it, you&#8217;re into the third chapter. Chapter three exhaustively covers animation. The detail is great and the authors even take the time touch on jQuery UI&#8217;s animation capabilities in addition to covering all of the core methods. I liked this chapter, &#8212; it seemed to cover pretty much everything, although I found myself disappointed with some of the code again:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">'&lt;div id=&quot;navigation_blob&quot;&gt;&lt;/div&gt;'</span><span class="br0">&#41;</span>.<span class="me1">css</span><span class="br0">&#40;</span><span class="br0">&#123;</span>
    width<span class="sy0">:</span> $<span class="br0">&#40;</span><span class="st0">'#navigation li:first a'</span><span class="br0">&#41;</span>.<span class="me1">width</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="sy0">,</span>
    height<span class="sy0">:</span> $<span class="br0">&#40;</span><span class="st0">'#navigation li:first a'</span><span class="br0">&#41;</span>.<span class="me1">height</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span>.<span class="me1">appendTo</span><span class="br0">&#40;</span><span class="st0">'#navigation'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>Let&#8217;s introduce some basic optimisations:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> nav <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'#navigation'</span><span class="br0">&#41;</span><span class="sy0">,</span>
    firstAnchor <span class="sy0">=</span> nav.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">'li:first a'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
$<span class="br0">&#40;</span><span class="st0">'&lt;div id=&quot;navigation_blob&quot;&gt;&lt;/div&gt;'</span><span class="br0">&#41;</span>.<span class="me1">css</span><span class="br0">&#40;</span><span class="br0">&#123;</span>
    width<span class="sy0">:</span> firstAnchor.<span class="me1">width</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="sy0">,</span>
    height<span class="sy0">:</span> firstAnchor.<span class="me1">height</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span>.<span class="me1">appendTo</span><span class="br0">&#40;</span>nav<span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>Chapter four is all about images, and takes the reader through the process of creating a simple lightbox effect. It also shows you how to download and &#8220;install&#8221; your typical jQuery lightbox plugin (in this case, <a href="http://colorpowered.com/colorbox/">ColorBox</a>). It continues to show you how to create a simple slideshow.</p>

<p>The bulk of this book was obviously written before 1.4 was released. I get the impression that, upon 1.4&#8217;s release, the authors quickly went through adding in some &#8220;actions&#8221; only made possible with 1.4. They covered the new way of creating elements in jQuery 1.4, which involves passing an object as the second argument to <code>jQuery()</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">'&lt;div/&gt;'</span><span class="sy0">,</span> <span class="br0">&#123;</span>
    text<span class="sy0">:</span> <span class="st0">'foo'</span><span class="sy0">,</span>
    click<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><span class="sy0">,</span>
    id<span class="sy0">:</span> <span class="st0">'muah'</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p>The book had the following to say:</p>

<blockquote><p>&#8220;If you use a jQuery method name like text, html, or val, it will use the jQuery methods to set the property. Everything else will be treated as an attribute, as done with the src property.&#8221;</p></blockquote>

<p>This isn&#8217;t entirely accurate. jQuery only uses certain methods &#8212; not all of them. Methods available for usage in this way are specified under <code>jQuery.attrFn</code>.</p>

<p>Continuing&#8230;</p>

<p>Chapter five brings with it a lot of UI icing&#8230; tooltips, menus, tabs and accordions. The book takes the reader through the processes involved in creating these interface elements. Just like all the other chapters, chapter five is littered with little titbits of useful information. For example, it covers event propagation and default event actions in pretty decent detail.</p>

<p>The next chapter is probably my favourite &#8212; it covers code construction and best practices, including namespacing, encapsulation, commenting, DRY, templating and feature detection! I was pleasantly surprised to see these topics covered in a book like this. Their templating techniques were a little lacking &#8212; I would&#8217;ve liked to see some custom-typed <code>&lt;script&gt;</code> elements (like in <a href="http://ejohn.org/blog/javascript-micro-templating/">Resig&#8217;s solution</a>), or perhaps some templates stuffed into HTML comments.</p>

<p>Chapter six continues by explaining Ajax and showing the reader what jQuery offers in the way of Ajax/XHR utilities. You&#8217;re also taken through the process of creating an Ajax-driven image gallery among some other gems.</p>

<p>I&#8217;m going to stop outlining the chapters now&#8230; I&#8217;m bored, and you&#8217;re probably not getting much from that (heck, you could probably just look through the <a href="http://www.sitepoint.com/books/jquery1/toc.php">TOC</a>). The rest of book covers forms, controls, dialogs, validation, lists, trees, tables, plugins, themes and some &#8220;advanced topics&#8221;. There&#8217;s also a hefty appendices that has bunch of useful information, including a brief JavaScript tutorial for those new to the language.</p>

<p>Just so we&#8217;re clear, this is a good book, and if you fit the bill of a front-end wizz that wants to pick up jQuery, then this book will easily deliver. There are a couple of oversights, but in a book over 400 pages long I&#8217;d say that&#8217;s pretty amazing! <a href="http://www.sitepoint.com/books/jquery1/authors.php">Earl Castledine and Craig Sharkie</a> have done a pretty awesome job!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/javascript/jquery-novice-to-ninja/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Trying to learn Java</title>
		<link>http://james.padolsey.com/general/trying-to-learn-java/</link>
		<comments>http://james.padolsey.com/general/trying-to-learn-java/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 23:25:14 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[University]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1031</guid>
		<description><![CDATA[I’m off to University in just over a month and I thought it’d be a good idea to get a head start, academically. I’ve applied to study Computer Science, and, as only sense dictates, the first language we touch upon will be Java, the big&#8230;]]></description>
			<content:encoded><![CDATA[<p>I’m off to University in just over a month and I thought it’d be a good idea to get a head start, academically. I’ve applied to study Computer Science, and, as only sense dictates, the first language we touch upon will be Java, the big brother of JavaScript… kidding; I can hear Crockford screaming! So, with all this spare time I&#8217;ve decided to learn Java, or, at least begin on the journey!</p>

<p>I downloaded Eclipse and the &#8220;Java runtime&#8221;, only, of course, to find out that I already had about 10 different Java runtimes already installed. I fired everything up and then stopped; I had absolutely no idea what to create&#8230; What can I say? The command-line doesn&#8217;t excite me! Yes, I know pretty much anything can be created with Java, even hardware-accelerated games, but all the beginner-tutorials out there only show you the monotonous command-line drivel.</p>

<p>I also purchased a book recommended by the University; I believe it&#8217;s the one we&#8217;ll be learning from in the first year. It&#8217;s called &#8220;Objects first with Java&#8221; and goes into a tremendous amount of (unnecessary?) detail; I haven&#8217;t really got past the first few pages. I&#8217;ll tell you something about objects; you&#8217;re never going to learn squat about them from tutorials or books. Yeh sure, you&#8217;ll get an idea about what they are but you&#8217;ll never appreciate the abstraction provided by OO language until you dive in.</p>

<p>Now, don&#8217;t get me wrong about this whole University thing; I am looking forward to the &#8220;experience&#8221; but I&#8217;m not exactly overly-excited about the impending course material. I haven&#8217;t even begun and I&#8217;m already finding it dull; I&#8217;ve no doubt that I&#8217;ll be pleasantly surprised though&#8230; I&#8217;m sure the first lecture will prove enthralling!</p>

<p>I&#8217;ll be honest with you; I&#8217;m only going to University because &#8220;that&#8217;s what one does after school&#8221;. Heck, most people go to Uni for exactly the same reason (they just don&#8217;t know it); it&#8217;s what&#8217;s expected of us. You can say what you want about it but essentially, University is yet another device used to extend and perpetuate the status-quo; i.e. us working and the government getting richer. I just can&#8217;t wait; out of uni with a load of debts and then into the monotony of a &#8220;career&#8221;. Eventually I&#8217;ll have additional burdens that will require monetary attention and before you know it I&#8217;ll be where most of the British upper-middle-class finds itself, paying off debts&#8230; living the dream!</p>

<p>Isn&#8217;t it amazing, I haven&#8217;t experienced any of this impending fate yet and I already have the capacity to be utterly dismissive and totally negative about it all! Here&#8217;s hoping the grass is greener!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/general/trying-to-learn-java/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Take a stand against IE!</title>
		<link>http://james.padolsey.com/general/take-a-stand-against-ie/</link>
		<comments>http://james.padolsey.com/general/take-a-stand-against-ie/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 10:52:46 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=1001</guid>
		<description><![CDATA[I&#8217;ve got a great idea; let&#8217;s annoy the hell out of 75% of IE6 users by showing them a &#8220;you should upgrade&#8221; message, even though <strong>none</strong> of them have the actual capability to upgrade! Seriously, what a superb idea! It&#8217;s like having a &#8220;fly to work&#8221;&#8230;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a great idea; let&#8217;s annoy the hell out of 75% of IE6 users by showing them a &#8220;you should upgrade&#8221; message, even though <strong>none</strong> of them have the actual capability to upgrade! Seriously, what a superb idea! It&#8217;s like having a &#8220;fly to work&#8221; sign instead of a train station, when everyone knows that only 25% of humans can actually fly!</p>

<p>Yes, a <A href="http://blog.digg.com/?p=878">recent survey by Digg</a> revealed that only one quarter of all IE6 users have the power to change. This minority is made up of two groups: those that simply don&#8217;t see a need to upgrade and those that prefer IE6 to other browsers.</p>

<p>So, without sounding too pessimistic, trying to get IE6 users to upgrade is almost entirely pointless! Your efforts would be better spent teaching 75% of humankind how to fly!</p>

<p>I haven&#8217;t really got a good idea; in fact, I&#8217;m equally as clueless as most of you&#8230; How on earth are we going to solve the IE problem, or, rather the &#8220;Microsoft&#8221; problem?</p>

<p>Have you ever read about that world record that was set when a bunch of people somewhere jumped up at exactly the same time? Speculation has it that the earth was temporarily knocked off its axis, which, consequently saved the earth from a massive meteor strike!? Well I haven&#8217;t, but I do have a similar idea that is almost guaranteed to work.</p>

<p>Imagine, if every single website on earth suddenly broke in IE &#8211; users of IE would be utterly confused and annoyed &#8211; there would be an epic stream of complaints battering every IT department this side of the sun! Eventually it would result in the demise of IE (all versions). So you see, it is possible! Together we can bring down IE, it just takes a tad of collaboration!</p>

<span id="more-1001"></span>

<h2>Kill it with <del datetime="2009-07-12T10:21:03+00:00">fire</del> apathy!</h2>

<p>It&#8217;s not irresponsible; it&#8217;s only logical.</p>

<p>I think the personality types associated with workers in this industry (the &#8220;web&#8221; industry) prevents us from taking the kind of action inherent in other FFS (frequently-found-striking) industries! At our fingertips we have the ability to destroy or to save; with a single line of code we can affect millions!</p>

<p>Take a stand! Indifference will, for once, save the world! <strong>Long live Web Standards</strong>!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/general/take-a-stand-against-ie/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Rant: &#8220;Crappy comments&#8221;</title>
		<link>http://james.padolsey.com/general/rant-crappy-comments/</link>
		<comments>http://james.padolsey.com/general/rant-crappy-comments/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 11:16:48 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Comments]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=872</guid>
		<description><![CDATA[
Okay, this really annoys me sometimes; you read a blog post or article, it was interesting, you scroll to the comments section looking for an interesting discussion regarding the content of the post but all you find is countless grammatical or technical corrections contributed by&#8230;]]></description>
			<content:encoded><![CDATA[
<p>Okay, this really annoys me sometimes; you read a blog post or article, it was interesting, you scroll to the comments section looking for an interesting discussion regarding the content of the post but all you find is countless grammatical or technical corrections contributed by &#8220;helpful&#8221; readers!</p>

<p>For me, the comments section of a blog post is where users can contribute thoughts concerning the material covered in the post; not spelling mistakes, or a complaint about the site&#8217;s content. Apparently not everyone feels this way, because whenever I go to read the comments there&#8217;s always a few egotistical children leaving comments about the damn grammar!</p>

<p>Now, I&#8217;ve probably done it a couple of times in the past myself but I&#8217;ve stopped &#8211; I eventually realised I was only doing it to gratify my own needs; I wasn&#8217;t really interested in the grammatical correctness of any post &#8211; my ego just required a frequent pampering, apparently in the form of grammatical superiority.</p>

<p>Sometimes it may be appropriate to point out these mistakes; if the mistake will cause obvious grief to other readers who take heed from the post then by all means contribute your correction, but if it&#8217;s a tiny, barely-noticeable mistake then please keep it to yourself&#8230; or, if you feel your alter-ego &#8220;Grammar Nazi&#8221; kicking in then, by all means, send the owner of the site an angry email.</p>

<p>I have a secret; I delete non-spam comments sometimes! Yes, it&#8217;s true! Do you know why? Because this is <em>my</em> website and as such I feel it my responsibility to police the content of it &#8211; if a comment is defamatory or just downright rude then I&#8217;ll delete it, or if I feel the comment adds absolutely nothing to the post then I&#8217;ll delete it. For example, if your comment contains just one word like &#8220;Wow!&#8221; or &#8220;First!&#8221; or &#8220;Interesting!&#8221; then it&#8217;ll probably be deleted; why are you wasting your time writing such drivel?</p>

<p>I rarely have a problem though; this is a tiny blog with a tiny readership; something I&#8217;ve come to appreciate greatly!</p>

<p>I do feel sorry for the guys at Smashing Magazine! With over 100,000 subscribers they really do get some crap appearing in their comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/general/rant-crappy-comments/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>I&#8217;m on Github!</title>
		<link>http://james.padolsey.com/javascript/im-on-github/</link>
		<comments>http://james.padolsey.com/javascript/im-on-github/#comments</comments>
		<pubDate>Sat, 16 May 2009 18:12:11 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[Github]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=818</guid>
		<description><![CDATA[
Yes, finally I&#8217;ve joined the masses on Github and I plan to sporadically share special things on there, starting with the following recent developments:

&#8220;literalHTML&#8221;

A tiny but powerful modification allowing you to specify HTML/DOM structures inline in your JavaScript code, an example:


<pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> className <span class="sy0">=</span> <span class="st0">'active'</span><span class="sy0">;</span>
<span class="kw2">var</span> myMenu&#8230;</pre>]]></description>
			<content:encoded><![CDATA[
<p>Yes, finally I&#8217;ve joined the masses on Github and I plan to sporadically share special things on there, starting with the following recent developments:</p>

<h2>&#8220;literalHTML&#8221;</h2>

<p>A tiny but powerful modification allowing you to specify HTML/DOM structures inline in your JavaScript code, an example:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> className <span class="sy0">=</span> <span class="st0">'active'</span><span class="sy0">;</span>
<span class="kw2">var</span> myMenu <span class="sy0">=</span> <span class="sy0">|</span>
    <span class="sy0">&lt;</span>ul<span class="sy0">&gt;</span>
        <span class="sy0">&lt;</span>li <span class="kw2">class</span><span class="sy0">=</span><span class="st0">&quot;{className}&quot;</span><span class="sy0">&gt;</span>Item <span class="nu0">1</span><span class="sy0">&lt;/</span>li<span class="sy0">&gt;</span>
        <span class="sy0">&lt;</span>li<span class="sy0">&gt;</span>Item <span class="nu0">2</span><span class="sy0">&lt;/</span>li<span class="sy0">&gt;</span>
        <span class="sy0">&lt;</span>li<span class="sy0">&gt;</span>Item <span class="nu0">3</span><span class="sy0">&lt;/</span>li<span class="sy0">&gt;</span>
    <span class="sy0">&lt;/</span>ul<span class="sy0">&gt;</span>
<span class="sy0">|;</span>
&nbsp;
<span class="co1">// myMenu is now a DOM object:</span>
myMenu.<span class="me1">nodeName</span><span class="sy0">;</span> <span class="co1">// &quot;ul&quot;</span>
myMenu.<span class="me1">childNodes</span><span class="sy0">;</span> <span class="co1">// [ &lt;li.active&gt;, &lt;li&gt;, &lt;li&gt; ]</span>
&nbsp;
<span class="co1">// Do something:</span>
jQuery<span class="br0">&#40;</span><span class="st0">'body'</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span>myMenu<span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>




<p><strong><a href="http://github.com/jamespadolsey/javascript-dom-general/tree/master">View here &raquo;</a></strong></p>


<h2>&#8220;getDescendants&#8221;</h2>

<p>Something I required for a project; a function to gather all descendant-elements down until a certain depth is reached:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<span class="kw2">div</span>&gt;</span>
    <span class="sc2">&lt;<span class="kw2">ul</span>&gt;</span>
        <span class="sc2">&lt;<span class="kw2">li</span>&gt;</span>Something <span class="sc2">&lt;<span class="kw2">strong</span>&gt;</span>interesting<span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">strong</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">li</span>&gt;</span>
    <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">ul</span>&gt;</span>
    <span class="sc2">&lt;<span class="kw2">p</span>&gt;</span>Something <span class="sc2">&lt;<span class="kw2">span</span>&gt;</span>else<span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">span</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">p</span>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">div</span>&gt;</span></pre></div></div>




<p>Examples:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> div <span class="sy0">=</span> document.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">'div'</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span>
getDescendants<span class="br0">&#40;</span>div<span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// -&gt; [ &lt;ul&gt;, &lt;p&gt; ]</span>
                        <span class="co1">// i.e. children</span>
getDescendants<span class="br0">&#40;</span>div<span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// -&gt; [ &lt;ul&gt;, &lt;p&gt;, &lt;li&gt;, &lt;span&gt; ]</span>
                        <span class="co1">// i.e. children + grandchildren</span>
getDescendants<span class="br0">&#40;</span>div<span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// -&gt; [ &lt;ul&gt;, &lt;p&gt;, &lt;li&gt;, &lt;span&gt;, &lt;strong&gt; ]</span>
                        <span class="co1">// i.e. children + grandchildren + great-grandchildren</span></pre></div></div>




<p><strong><a href="http://github.com/jamespadolsey/javascript-dom-general/tree/master">View here &raquo;</a></strong></p>

<p>I&#8217;ll hopefully be adding to the repositroy with new exciting discoveries in the near future; visit <a href="http://github.com/jamespadolsey">my profile</a> and &#8220;follow me&#8221; to stay updated!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/javascript/im-on-github/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Learning jQuery 1.3, the book</title>
		<link>http://james.padolsey.com/javascript/learning-jquery-13-the-book/</link>
		<comments>http://james.padolsey.com/javascript/learning-jquery-13-the-book/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 21:55:54 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=711</guid>
		<description><![CDATA[Not too long ago I acquired a copy of &#8220;<a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a>&#8220;, a recently released &#8216;PACKT&#8217; publication written by Karl Swedberg and Jonathan Chaffer. The only books I&#8217;ve previously owned relating to web development were not framework/library specific so reading this one was a totally&#8230;]]></description>
			<content:encoded><![CDATA[<p>Not too long ago I acquired a copy of &#8220;<a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a>&#8220;, a recently released &#8216;PACKT&#8217; publication written by Karl Swedberg and Jonathan Chaffer. The only books I&#8217;ve previously owned relating to web development were not framework/library specific so reading this one was a totally new experience.</p>

<p>The book is mostly aimed at beginners but does cover some more advanced topics so may be of interest to the more savvy web designer or developer. Actually, anyone wanting a solid jQuery reference would benefit from this book!</p>

<p>I&#8217;d guess that one of the troubles with writing a book <em>just</em> about a specific topic is that you&#8217;re limited to its confines. This book does not start by discussing the DOM API or JavaScript itself, but instead it begins by first explaining the intent of jQuery and then by detailing the jQuery wrapper function and how you can utilise the power of CSS within this magical dollar symbol. jQuery is wonderful but, in my opinion, without a solid foundation in JavaScript you can <em>never</em> be as good as you <em>could</em> be.</p>

<p>The authors did a wonderful job and I don&#8217;t think anyone could ask for a better book about jQuery but I cannot help but raise the question of whether or not jQuery is <em>the</em> practical place to start.</p>

<p>I have this image in my head of some hotshot interface designer longing for some hotshot Ajax&#8217;y coolness to suit his ego; he wanders into <a href="http://www.waterstones.com/waterstonesweb/home.do">Waterstones</a> and picks up a copy of this jQuery book he&#8217;d heard of, he takes it home, and willingly begins on the long journey of learning &#8220;jQuery&#8221;. If the world were what I wanted, then this guy would soon realise the error of his ways and how he should have learnt JavaScript before venturing into it&#8217;s squeeky clean abstractions; but, unfortunately, the world is not like that; the reality is more upsetting &#8211; not only will this designer never realise the error of his ways but he&#8217;ll live on, writing jQuery everyday, creating bouncy effects and &#8220;jQueryfied&#8221; web interfaces. Why is that a problem? &#8211; Because he will never be able to program in JavaScript he&#8217;ll lack the fundamental knowledge that would otherwise ensure him complete cross-browser and timeless sanity!</p>

<span id="more-711"></span>

<p>Did you see that!? While discussing the necessity of learning JavaScript before jQuery, I went off at a tangent; Something book authors are not afforded the luxury of doing&#8230; But that isn&#8217;t to say it was a worthless moment! That&#8217;s why books bug me a little, it&#8217;s all about size, specification and compensation! It&#8217;s never really about the information. <sup>1</sup></p>

<h2>Back to the book&#8230;</h2>

<p>The book goes into considerable depth and manages to cover most, if not all, aspects of jQuery. In addition to feature descriptions and examples, Karl and Jonathan discuss best practices and continually advise the reader on the best course of action in various situations. jQuery&#8217;s UI framework and other various plugins are also discussed near the end.</p>

<p>I only have a couple of concerns about the book and its content. I don&#8217;t feel that the surrounding technologies are given enough time in the book. A preliminary chapter on the basics of JavaScript (and the DOM) would&#8217;ve certainly benefited beginners. While the average reader might not see the relevance of such a chapter, they&#8217;ll probably have a better understanding of the syntactic discrepancies of jQuery because of it. Even though having knowledge of JavaScript is a noted prerequisite, I doubt many readers of the book would accept this necessity. Beginners are vulnerable to the classic mistake of learning a framework before learning the language on which it&#8217;s based.</p>

<p>The only issue with offering such a chapter would be that half the readers would probably find it either useless or not worth reading&#8230; yet another reason why books bug me, you&#8217;ve got to cater to such a large audience with such varying motives that you&#8217;re bound to disappoint at least a few of them!</p>

<p>I only have one other tiny problem with the book, and this is very specific issue and probably a little over-zealous of me to even mention it: In the first chapter the authors state that without jQuery&#8217;s bespoke <code>ready</code> event you&#8217;d have to rely on the <code>onload</code> event to run code when the DOM is loaded. Then they continue by saying how you&#8217;d have to bind a named function to the event by obtrusively placing it in the HTML (<code>&lt;body onload="..."&gt;</code>). These assumptions highlight a notable problem with jQuery and its &#8220;marketing&#8221; techniques: The conception that unobtrusive JavaScript is only possible with jQuery is far too widespread, even the assumption that jQuery makes unobtrusive coding easy is, in my view, rubbish. There are far more respectable ways to market a product (i.e. jQuery) than slamming the competition (i.e. JavaScript <strong>without</strong> jQuery). <sup>2</sup></p>

<h2>Conclusions</h2>

<p>The content of the book, as it is, is <em>definitely</em> up to scratch. The only issues I have are more theoretical and are largely unrelated to this particular publication.</p>

<p>If you are considering buying a book of this type or are possibly on the edge of a decision then I absolutely suggest this one! Everything you&#8217;d want to know about the jQuery library is neatly squeezed inside the covers of &#8220;<a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a>&#8220;. Don&#8217;t be put off by my negativity; like I said, those are just a couple of my opinions concerning the general approach of books like these, not the content of this particular one.</p>

<p>Even if you&#8217;re not considering buying any book at all, I would definitely consider looking at this one. Although, if you&#8217;re a total beginner I might suggest a more gentle and progressive introduction to the world of JavaScript, possibly &#8220;<a href="http://oreilly.com/catalog/9780596000486/">JavaScript: The Definitive Guide</a>&#8220;. If you can&#8217;t be bothered with &#8220;regular JS&#8221; and just want to get at the cool stuff then I urge you to reconsider your stance. JavaScript isn&#8217;t as bad as people make it out to be, and it&#8217;s only getting more popular; learn JavaScript, then learn jQuery (or a library/framework of your choice).</p>

<p><small><sup>1</sup> &#8211; By this, I mean &#8220;information&#8221; is rarely the prime concern when publishing a book. While creating an informative book may be the sole objective of the author it&#8217;s not going to be the publisher&#8217;s primary concern!</small><br />
<small><sup>2</sup> &#8211; Library&#8217;less JavaScript is not in competition with any particular library but the marketing techniques of these libraries has created this dillusion; that JavaScript is not good enough, and that somehow it&#8217;s all too hard&#8230;</small>
</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/javascript/learning-jquery-13-the-book/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dear Apple&#8217;s flock&#8230;</title>
		<link>http://james.padolsey.com/general/dear-apples-flock/</link>
		<comments>http://james.padolsey.com/general/dear-apples-flock/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 14:14:36 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://james.padolsey.com/?p=549</guid>
		<description><![CDATA[When do you know you&#8217;ve gone crazy? &#8211; When you&#8217;re more impressed by a tool than what you can create with it!

I reckon the great majority of people in this industry would unconditionally subscribe to the conception that an Apple Mac makes you more&#8230;]]></description>
			<content:encoded><![CDATA[<p>When do you know you&#8217;ve gone crazy? &#8211; When you&#8217;re more impressed by a tool than what you can create with it!</p>

<p>I reckon the great majority of people in this industry would unconditionally subscribe to the conception that an Apple Mac makes you more productive. This little white magical box somehow enhances your ability to produce amazing things, right? Oh and let&#8217;s not forget all the other Apple stuff. The iPhone, Ipod, iMac, MacBook, Mac mini &#8211; they&#8217;re all magical creations tht enhance our existence!</p>


<p>I guess it&#8217;s all down to the modern-day infatuation with shiny new technology coupled with manipulative marketeers operating you like a puppet! I mean, seriously, do any of you think that Apple, the corporation, cares a smidge about how productive you are or how innovative your creations are? They don&#8217;t! They really don&#8217;t give a damn!</p>

<p>Don&#8217;t get me wrong, I love new technology &#8211; I think it&#8217;s great. But I&#8217;m not going to consign to this crazed kind of addiction that so many people have. No, I don&#8217;t need that new MacBook, I&#8217;m perfectly happy with my three year old PC running XP! And speaking of Operating Systems, no! I don&#8217;t need Vista, OSX or Windows 7 &#8211; I can manage quite happily without all that!</p>

<h2>Real web designers use Macs!</h2>

<p>Oh I see; all this time I was under the delusion that one&#8217;s credibility in this industry was platform agnostic but obviously I&#8217;m totally wrong. What was I thinking!? Of course, I see it now, the extent to which a developer is good at his/her job can be solely measured by the software and hardware they use! How could I have ever thought otherwise!?</p>

<p><strong>Grow up</strong>! This industry isn&#8217;t about my hammer being better than yours; it&#8217;s about what I create with my hammer, and what you create with yours! Like the old saying goes &quot;A bad workman blames his tools&quot; &#8211; actually, I&#8217;d take it further: &quot;A bad workman feels so passionately about his tools that he values them more than his actual work!&quot;</p>

<p>I actually find this quite comical:</p>

<blockquote><p>There is absolutely no reason in the world you should use anything other than Keynote. Period. I don’t care if you’re on a PC — if you’re serious about speaking, buy a MacBook just for presenting. There is an astounding difference (not an exaggeration) between the tools, canvas placement, typographic control, and overall aesthetics in Keynote compared to PowerPoint. Once you become familiar with Keynote, which isn’t an arduous process, the productivity and just plain enjoyment you’ll experience using it over PowerPoint is completely worth any switching costs.</p></blockquote>

<p>Obviously <a href="http://cameronmoll.com/archives/2009/02/20_tips_better_conference_speaking/">Cameron Moll feels</a> that to succeed as a speaker you MUST BUY A MACBOOK!</p>

<p>I&#8217;m going to stop now, I feel I may explode!</p>

<p><strong>If you suck at something on a PC you will also suck at it on a Mac!</strong></p>

<p>PS, congratulations Apple, you&#8217;ve actually made me want to hold on to my PC out of protest!</p>]]></content:encoded>
			<wfw:commentRss>http://james.padolsey.com/general/dear-apples-flock/feed/</wfw:commentRss>
		<slash:comments>78</slash:comments>
		</item>
	</channel>
</rss>
