<?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>islandgrl.net &#187; wordpress</title>
	<atom:link href="http://islandgrl.net/topics/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://islandgrl.net</link>
	<description>home of hannah gray, bookworm, geek, cat-lover</description>
	<lastBuildDate>Fri, 17 Feb 2012 20:38:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>jQuery vs Prototype &#8211; WordPress Gone Astray?</title>
		<link>http://islandgrl.net/2007/01/04/jquery-vs-prototype-wordpress-gone-astray/</link>
		<comments>http://islandgrl.net/2007/01/04/jquery-vs-prototype-wordpress-gone-astray/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 19:41:35 +0000</pubDate>
		<dc:creator>hannah</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://islandgrl.net/2007/01/04/jquery-vs-prototype-wordpress-gone-astray</guid>
		<description><![CDATA[WordPress 2.0 essentially marked the final leap of the WP team in joining the Web 2.0 bandwagon&#8230; We have a big friendly typeset, drag-and-drop widgets, AJAXified posting and moderating tools. And with 2.1, we will be getting a JavaScript framework. This doesn&#8217;t mean much to the average WP user, but to developers, its huge. Every [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://islandgrl.net/wp-content/uploads/2007/01/wp-2.0-square-button.gif" height="112" width="112" border="0" align="right" hspace="4" vspace="4" alt="Wp-2.0-Square-Button" class="noborder"/>WordPress 2.0 essentially marked the final leap of the WP team in joining the Web 2.0 bandwagon&#8230; We have a big friendly typeset, drag-and-drop widgets, AJAXified posting and moderating tools.  And with 2.1, we will be getting a JavaScript framework.  </p>
<p>This doesn&#8217;t mean much to the average WP user, but to developers, its huge.  Every time a WordPress blog loads, the viewer is now downloading a 48kb nugget of JS &#8211; the <a href="http://prototype.conio.net/">Prototype Framework</a>.  So as a developer &#8211; if I want to make a shiny 2.0&#8242;ish plugin, I&#8217;ve got to use Prototype as a backend.  Or I have to force everyone to use something else, of questionable compatibility, which will add yet more bulk to WP.  Alex King has embraced Prototype with his <a href="http://alexking.org/projects/wordpress">Share This</a> plugin.  I&#8217;m sure others are soon to follow.  But to be honest, I can&#8217;t see why the whole community isn&#8217;t throwing a colossal fit and threatening to dunk the WP dev team in a nice cold lake.</p>
<p>I admit, I&#8217;m biased. I&#8217;ve been developing sites with the JQuery framework for 4+ months now.  Back in August of 2006 I realized that all this AJAX/2.0/Rails/Blah nonsense wasn&#8217;t going to fade away, so I best bite the bullet and learn what all the hype was about. </p>
<p>So I looked at Prototype,  Scriptalicious, Ruby, Rails, read about AJAX&#8230; posted a forlorn &#8220;help me, i&#8217;m drowning&#8230;&#8221; message on the Apple web dev mailing list, and got one very short reply: &#8220;JQuery.  I&#8217;ll see you on their dev list soon <img src='http://islandgrl.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8221;</p>
<p>Prototype does some nice things for you, don&#8217;t get me wrong.  But Prototype on its own still requires a lot of down-and-dirty javascripting PLUS a learning curve of Prototype syntax, functions and classes.  Ick.  JQuery, however, does many simple and not-so-simple tasks for you with only a line or two of code.  Sure, there&#8217;s a learning curve, but at least there is a nice juicy carrot at the end.  I don&#8217;t want to do loads of down-and-dirty scripting.  This is why I looked for a framework in the first place.</p>
<p>There are a variety of examples of how JQuery uses cleaner, more logical, shorter code on the <a href="http://jquery.com/blog/2006/08/20/why-jquerys-philosophy-is-better/">JQuery blog</a> itself.  These are a little technical though, and I wanted to provide a <span style="font-size:1.2em">quick glimpse that might be more relevant to Plugin Developers:</span></p>
<h3>So you want to hide and show a div, and you want it to slowly fade in and fade out when you toggle the hide/show.</h3>
<p><em>JQuery (library weighing in at 20kb):<br />
</em>
<div class="code">$(&#8220;#ohmy&#8221;).show(&#8220;slow&#8221;);</div>
<p><em>Prototype (48kb on its own) </em>can&#8217;t do this.  We need to add <a href="http://script.aculo.us/">Scriptaculous</a> + Prototype, which has a combined bulk of <strong>228 kb!<br />
</strong></p>
<div class="code">Effect.toggle(&#8216;ohmy&#8217;,'appear&#8217;);</div>
<h3>Okay&#8230; Other than the added size and extra includes, this doesn&#8217;t seem all that bad.  But what if we don&#8217;t want to add an onclick=&#8221;javascript: blah&#8221; to every scripted element? </h3>
<p><em>JQuery (20kb):</em></p>
<div class="code">$(&#8220;.toggle&#8221;).click(function(){<br />
$(#ohmy).hide(&#8220;slow&#8221;);<br />
return false;<br />
});</div>
<p><em>Prototype (48kb on its own) can&#8217;t do this.  Scriptaculous + Prototype (228kb) can&#8217;t do this either.  </em>We need Scriptaculous + Prototype + <a href="http://www.bennolan.com/behaviour/">Behaviour</a>, weighing in at <strong>236kb<br />
</strong></p>
<div class="code">
var myrules = {<br />
&#8216;.toggle&#8217; : function(element){<br />
Effect.toggle(&#8216;ohmy&#8217;,'appear&#8217;);<br />
}<br />
}<br />
};<br />
Behaviour.register(myrules);</div>
<p>NOTE:  As <a href="http://alterform.com/">Nate</a> pointed out, this is wrong.  The $$(&#8216;.toggle&#8217;) function will work just fine.  However, I&#8217;m leaving the Behaviour example up to illustrate what a fairly savy coder, new to ProtoType, was able to come up with in 2+ hours of research.</p>
<h3>Doing something a little more advanced&#8230; odd/even &#8216;zebra&#8217; tables without php overhead:</h3>
<p>(this one was pulled from the <a href="http://jquery.com/blog/2006/10/18/zebra-table-showdown/">JQuery blog</a>)</p>
<p><em>JQuery (20kb):</em></p>
<div class="code">$(&#8220;tr:nth-child(odd)&#8221;).addClass(&#8220;odd&#8221;);</div>
<p><em>Prototype (48kb): </em></p>
<div class="code">$A(document.getElementsByTagName(&#8220;table&#8221;)).each(function(table){<br />
  $A(table.getElementsByTagName(&#8220;tr&#8221;)).each(function(row,i){<br />
    if ( i % 2 == 1 )<br />
      Element.addClassName( row, &#8220;odd&#8221; );<br />
  });<br />
});</DIV></p>
<p><img src="http://islandgrl.net/wp-content/uploads/2007/01/jquery-logo.png" height="31" width="173" border="0" align="left" hspace="4" vspace="4" alt="Jquery-Logo" class="noborder"/>So&#8230;  JQuery: Get stuff done with less code!  For 1/11th the size of prototype+scriptaculous+behaviour, JQuery  provides tons of USEFUL stuff built in, no need for additional overhead libraries.</p>
<p>That&#8217;s my perspective.  I don&#8217;t *LOVE* to code for the sheer joy of it.  I DO love to see my ideas and visions become reality.  I like pretty gadgets, including those that are browser-based.  I think this is where many of the WordPress plugin/extension developers are coming from &#8211; we want more shinys in our blogs!  Thus far, WordPress has done a PHENOMENAL job of making plugin development simple, logical, and intuitive.  I picked up WP Plugin syntax in about an hour.  Why ruin the ease-of-extension movement now?</p>
<p>And if you want to try JQuery with WordPress&#8230; Head on over to Dan Atkinson&#8217;s site for his <a href="http://www.dan-atkinson.com/wp/index.php/jquery-103-for-wordpress/">JQuery with WP Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://islandgrl.net/2007/01/04/jquery-vs-prototype-wordpress-gone-astray/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

