<?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>The Web Development Blog &#187; Prototype</title>
	<atom:link href="http://www.thewebdevelopmentblog.com/tag/prototype/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thewebdevelopmentblog.com</link>
	<description>News, tips, scripts and tutorials for web developers.</description>
	<lastBuildDate>Sun, 09 May 2010 12:19:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Javascript Libraries: Prototype or jQuery?</title>
		<link>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 04:18:46 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Javascript Libraries]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=272</guid>
		<description><![CDATA[A year ago the answer was easy, Prototype. Today jQuery has grown enormously and has the largest active community out of all the Javascript libraries. But is it the right choice for you? And what is a Javascript library anyway? What is a Javascript Library? Anyone who&#8217;s ever done serious coding with Javascript knows that [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago the answer was easy, Prototype. Today jQuery has grown enormously and has the largest active community out of all the Javascript libraries. But is it the right choice for you? And what is a Javascript library anyway?</p>
<p><span id="more-272"></span></p>
<p><strong>What is a Javascript Library?</strong></p>
<p>Anyone who&#8217;s ever done serious coding with Javascript knows that to get code to work cross-browser is a nightmare. Internet Explorer likes one way, Safari another, and Firefox another. It can be quite time consuming. This is where the Javascript libraries come to save the day! Hurray! Javascript libraries take the hassle out of coding for cross browser by extending Javascript so you don&#8217;t have to waste time developing for each browser.</p>
<p><strong>So which one to choose?</strong></p>
<p>There are two main Javascript libraries which are really in play, those are <a href="http://www.prototypejs.org" target="_blank">Prototype</a> and <a href="http://jquery.com/" target="_blank">jQuery</a>. There is also <a href="http://mootools.net/" target="_blank">MooTools</a>, however it is not anywhere near as widely used as Prototype and jQuery. That&#8217;s not to say it&#8217;s not as good, but I&#8217;m just going to compare the two leaders. It is important to note, there is no right or wrong answer, there is just preferences</p>
<p><strong>Prototype &#8211; The Grandfather</strong></p>
<p>It&#8217;s older but wiser. The key focus of Prototype is that it&#8217;s not really  designed to re-work the way Javascript is written, but to make your code more stable across more browsers and extented Javascript&#8217;s capabilities . Prototype builds on what&#8217;s already in Javascript, so you generally still get to do Javascript coding. It doesn&#8217;t build in fancy effects etc like jQuery does, it has it&#8217;s little sister <a href="http://script.aculo.us/" target="_blank">scriptaculous</a> to do that for it. One issue with Prototype is size, jQuery is available minified and gzipped, so it&#8217;s ready to go at 19kb. Prototype doesn&#8217;t have this available which is definitely hurting it&#8217;s numbers with younger developers. To gzip javascript yourself using PHP see my <a title="Jason Stockton, Web Developer, Javascript Gzip script" href="http://thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/" target="_blank">gzip script here</a>.</p>
<p>So why have I dubbed it &#8220;The Grandfather&#8221; and will this effect future development?</p>
<p>The problem with Prototype is it is becoming less and less active whilst jQuery becomes more and more active. More and more sites are switching to the hip young jQuery. Key switchers here are Twitter, Digg, NBC and the list goes on. So is the lack of progress going to affect it&#8217;s future? Right now no, but fast forward a year from now, if it&#8217;s still as inactive as it is now as newer browsers come out it&#8217;s going to quickly die out.</p>
<p>Prototype is still very stable and well featured, so it&#8217;s not to be overlooked.</p>
<p><strong>jQuery &#8211; The Cool Guy</strong></p>
<p>In contrast to Prototype, jQuery is built to reshape how Javascript is written and make it faster to write scripts. In short it does the hard work for you. jQuery is now the most widely used and supported Javascript library out there. There are literally hundreds of plugins, possibly thousands and the support is only growing. According to <a href="http://mootools.net/slickspeed/" target="_self">SlickSpeed</a> jQuery is significantly faster than Prototype, with the latest release said to be much much faster again. We&#8217;re only talking milliseconds so it&#8217;s not necessarily a huge deal but it&#8217;s always better to shave off time where possible.  It can take a bit of getting used to if you&#8217;re an advanced Javascript developer, but it seems like it will be of benefit in the long term. If you haven&#8217;t learnt Javascript before, jQuery can make it easier for you to get started making great scripts today.</p>
<p><strong>So which to choose?</strong></p>
<p>Ultimately it&#8217;s up to you, if you can&#8217;t decide, you can <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" target="_blank">use both</a>. I myself have been using Prototype for sometime and it is implemented in just about all of my sites AND I have built my own set of functions to compliment it. Having said that, the temptation to trial jQuery has gotten too great so I will be using both for a period of time before weening out Prototype now that jQuery can do pretty much all that Prototype can do, plus do it <strong>some of it</strong> easier.</p>
<p>They&#8217;re both great libraries and each have their pros and cons. jQuery is just hitting more of the pros today.</p>
<p><strong><a href="http://www.prototypejs.org" target="_blank">Download Prototype here</a></strong></p>
<p><strong><a href="http://jquery.com/" target="_blank">Download jQuery here</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding the X &amp; Y coordinates of an element relative to the entire page using Javascript</title>
		<link>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 08:16:48 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=187</guid>
		<description><![CDATA[It&#8217;s really easy to get the position of an element relative to it&#8217;s parent element, but what if you wanted to get it&#8217;s position relative to the entire page (viewport)? There&#8217;s no javascript call to do this, but here is a function to get the elements x &#38; y coordinates. If you use the prototype [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s really easy to get the position of an element relative to it&#8217;s parent element, but what if you wanted to get it&#8217;s position relative to the entire page (viewport)? There&#8217;s no javascript call to do this, but here is a function to get the elements x &amp; y coordinates.</p>
<p><span id="more-187"></span></p>
<p>If you use the <a href="http://www.prototypejs.org" target="_blank">prototype javascript framework</a> there is a call built in! Handy&#8230;</p>
<p><strong>Here&#8217;s the code for Prototype users:</strong></p>
<p><code>var pos = $("<em>elementID</em>").viewportOffset();<br />
var x = pos[0];<br />
var y = pos[1];</code></p>
<p>Nice and easy&#8230;</p>
<p>For those of you who <strong>don&#8217;t</strong> use prototype, below is a function you can use to get the X &amp; Y coordinates relative to the page (viewport).</p>
<p><strong>The Function:</strong></p>
<pre><code>function viewportOffset(forElement) {
	var valueT = 0, valueL = 0;&lt;
	var element = document.getElementById(forElement);
	do {
		valueT += element.offsetTop  || 0;
		valueL += element.offsetLeft || 0;
		if (element.offsetParent == document.body) break;
	} while (element = element.offsetParent);
	element = forElement;
	do {
		if (element.tagName == 'BODY') {
			valueT -= element.scrollTop  || 0;
			valueL -= element.scrollLeft || 0;
		}
	} while (element = element.parentNode);
	return [valueL, valueT];
}</code></pre>
<p><em>This is a modified function from the </em><em><a href="http://www.prototypejs.org" target="_blank">prototype framework</a></em>.</p>
<p><strong>Calling The Function:</strong></p>
<p><code>var pos = viewportOffset("<em>elementID</em>");<br />
var x = pos[0];<br />
var y = pos[1];</code></p>
<p>I tried several of the functions on various blogs etc none of them seemed to return anything but 0 in Safari. The above has been tested and works in the latest versions Safari, Firefox, IE and Opera.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
