<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/1.5" --><rss 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>John Resig</title>
	<link>http://ejohn.org</link>
	<description>Blog, Projects, and Links</description>
	<pubDate>Tue, 08 Jul 2008 16:09:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5</generator>
	<language>en</language>

		<geo:lat>42.381929</geo:lat><geo:long>-71.099084</geo:long><image><link>http://ejohn.org/</link><url>http://ejohn.org/files/jeresig-wordpress-sm.jpg</url><title>John Resig (ejohn.org)</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/JohnResig" type="application/rss+xml" /><feedburner:emailServiceId>189497</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><item>
		<title>jQuery LiveSearch</title>
		<link>http://ejohn.org/blog/jquery-livesearch/</link>
		<comments>http://ejohn.org/blog/jquery-livesearch/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 08:14:21 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>javascript</category>
                <category>jquery</category>
		<guid>http://ejohn.org/blog/jquery-livesearch/</guid>
		<description><![CDATA[A fun blog post popped up yesterday in which John Nunemaker ported a Quicksilver-style Live Search to jQuery. Taking a look at his code, I decided to have a little fun and re-port it to jQuery - trying to use the functional style that jQuery promotes. I think the end result is quite simple and [...]]]></description>
			<content:encoded><![CDATA[	<p>A fun blog post popped up yesterday in which John Nunemaker ported a <a href="http://orderedlist.com/articles/live-search-with-quicksilver-style-for-jquery">Quicksilver-style Live Search to jQuery</a>. Taking a look at his code, I decided to have a little fun and <a href="http://ejohn.org/apps/livesearch/">re-port</a> it to jQuery - trying to use the functional style that jQuery promotes. I think the end result is quite simple and elegant.</p>
	<p>The <a href="http://ejohn.org/apps/livesearch/jquery.livesearch.js">final code</a> - compare with <a href="http://orderedlist.com/demos/quicksilverjs/javascripts/jquery.livesearch.js">John's port</a>:</p>
	<div class="syntax_hilite">
<div id="js-1">
	<div>jQuery.<span style="color: #006600;">fn</span>.<span style="color: #006600;">liveUpdate</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span>list<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; list = jQuery<span style="color:#008800; font-weight:bold;">&#40;</span>list<span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p>&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#008800; font-weight:bold;">&#40;</span> list.<span style="color: #006600;">length</span> <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> rows = list.<span style="color: #006600;">children</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color:#008800; font-weight:bold;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; cache = rows.<span style="color: #006600;">map</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">innerHTML</span>.<span style="color: #006600;">toLowerCase</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span><br />
&nbsp; &nbsp; &nbsp; .<span style="color: #006600;">keyup</span><span style="color:#008800; font-weight:bold;">&#40;</span>filter<span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">keyup</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; .<span style="color: #006600;">parents</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">submit</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #003366; font-weight: bold;">function</span> filter<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> term = jQuery.<span style="color: #006600;">trim</span><span style="color:#008800; font-weight:bold;">&#40;</span> jQuery<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">val</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">toLowerCase</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#41;</span>, scores = <span style="color:#008800; font-weight:bold;">&#91;</span><span style="color:#008800; font-weight:bold;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#008800; font-weight:bold;">&#40;</span> !term <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; rows.<span style="color: #006600;">show</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; rows.<span style="color: #006600;">hide</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p>&nbsp; &nbsp; &nbsp; cache.<span style="color: #006600;">each</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span>i<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> score = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">score</span><span style="color:#008800; font-weight:bold;">&#40;</span>term<span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#008800; font-weight:bold;">&#40;</span>score &gt; <span style="color: #CC0000;">0</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span> scores.<span style="color: #006600;">push</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#91;</span>score, i<span style="color:#008800; font-weight:bold;">&#93;</span><span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p>&nbsp; &nbsp; &nbsp; jQuery.<span style="color: #006600;">each</span><span style="color:#008800; font-weight:bold;">&#40;</span>scores.<span style="color: #006600;">sort</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span>a, b<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> b<span style="color:#008800; font-weight:bold;">&#91;</span><span style="color: #CC0000;">0</span><span style="color:#008800; font-weight:bold;">&#93;</span> - a<span style="color:#008800; font-weight:bold;">&#91;</span><span style="color: #CC0000;">0</span><span style="color:#008800; font-weight:bold;">&#93;</span>;<span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jQuery<span style="color:#008800; font-weight:bold;">&#40;</span>rows<span style="color:#008800; font-weight:bold;">&#91;</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color:#008800; font-weight:bold;">&#91;</span><span style="color: #CC0000;">1</span><span style="color:#008800; font-weight:bold;">&#93;</span> <span style="color:#008800; font-weight:bold;">&#93;</span><span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">show</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
&nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
<span style="color:#008800; font-weight:bold;">&#125;</span>;</div>
	</div>
</div>
	<p>A couple points to note:</p>
	<ul>
	<li>.liveUpdate() no longer takes an element ID - it now accepts any jQuery selector (this is the only notable API change that I made).</li>
	<li>All state is stored in simple variables and accessed via closures, as opposed to as properties of an instance object.</li>
	<li>Only one function is used - and that's stored away within the function itself (greatly simplifying the resulting code).</li>
	<li>DOM queries are only done once and cached up front.</li>
	<li>.map() is used to simplify the creation of new arrays of information.</li>
	</ul>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5622" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/329803747" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/jquery-livesearch/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fjquery-livesearch%2F</feedburner:awareness></item>
		<item>
		<title>jQuery Plugins, Size, and Storage</title>
		<link>http://ejohn.org/blog/jquery-plugins-size-and-storage/</link>
		<comments>http://ejohn.org/blog/jquery-plugins-size-and-storage/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 15:02:35 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>jquery</category>
                <category>javascript</category>
		<guid>http://ejohn.org/blog/jquery-plugins-size-and-storage/</guid>
		<description><![CDATA[There is no such thing as a JavaScript plugin contends James Coglan. I completely agree that there are no, specific, techniques within the JavaScript language that make "plugins" possible (such as the ability to namespace code and import it, or some such).

HOWEVER - I will contend that such a thing as plugins exist and are [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://blog.jcoglan.com/2008/07/02/there-is-no-such-thing-as-a-javascript-plugin/">There is no such thing as a JavaScript plugin</a> contends James Coglan. I completely agree that there are no, specific, techniques within the JavaScript language that make "plugins" possible (such as the ability to namespace code and import it, or some such).</p>
	<p>HOWEVER - I will contend that such a thing as plugins exist and are logically distinct from "random JavaScript code that manipulates other JavaScript code" as long as the following points are met:</p>
	<ol>
	<li>There have to be explicit points upon which a plugin can attach. James notes the most common one in jQuery (jQuery.fn) but we have tons more - events, animations, selectors - all over the board for developers to snap in to.</li>
	<li>Even more importantly: Those points have to be documented or, at the very least, be under some sort of agreement that they will be treated like a normal piece of the user-facing API. In jQuery we treat all plugin extension points as "user-facing API" and only ever change them in major releases (if at all) and always provide an alternative for authors to use.</li>
	<li>Finally, there has to be some sort of repository for navigating these plugins. This is a huge differentiator. Simply referring to "code in the wild" as plugins doesn't really cut it if there's no commitment to hosting them and keeping their documentation and examples alive.</li>
	</ol>
	<p>We take our plugin architecture very seriously in the jQuery project and are constantly looking for ways to improve (looking at plugins, reading their code, seeing what we can provide to make their lives easier).</p>
	<hr/>
	<p>Alex Russell of Dojo recently built a <a href="http://www.sitepen.com/blog/2008/07/01/dojo-in-6k/">sleek 6kb version</a> of Dojo - presumably for use on mobile platforms. He states in his post that:</p>
	<blockquote><p>Even so-called “lightweight” libraries like jQuery are far too heavy for some environments…not because they (like Dojo) pull in all the code needed to use them, but because they do it all up-front. Often the best time to pay the expense of loading, parsing, and executing JavaScript code is when the user takes an action that needs the enhancement to run.</p></blockquote>
	<p>The way it's worded you would assume that you were paying a large, up-front, cost to using jQuery when, in fact, there is very little overhead. jQuery <a href="http://ejohn.org/blog/library-loading-speed/">has been shown</a> to be the fastest loading JavaScript library for non-cached code and considerably fast for cached code.</p>
	<p>Arguably a mini-Dojo would be able to provide an extra edge in this respect - however any gains that you would make up-front (which would be minimal - mini-Dojo is only about half the size of jQuery, as it stands) would have to contend with any future overhead incurred by loading additional components at a later time.</p>
	<p>I frequently queue up long pages to read on my iPhone while I travel the subway system here in Boston and I think I'd be quite upset if I got halfway through a page, clicked a hide/show link, and found out that the action wasn't able to work since the requisite functionality hadn't been loaded yet.</p>
	<p>There is a cost to loading "all" of jQuery up front, absolutely - however there are numerous benefits: It's highly cacheable, you never have to worry about what you do/don't have loaded, the API, documentation, tutorials, and examples are all dramatically simpler since you never have to worry about having extra components or making sure that they're being included correctly.</p>
	<p>And, as always, if you're particularly excited about breaking jQuery down into little chunks you can grab the <a href="http://docs.jquery.com/Downloading_jQuery#Subversion_.28SVN.29">individual pieces from SVN</a> and build a custom copy.</p>
	<hr/>
	<p>I was out of town when it happened but the release of the <a href="http://code.google.com/apis/ajaxlibs/documentation/">Google Ajax Library CDN</a> (which includes the current release of <a href="http://code.google.com/apis/ajaxlibs/documentation/#jquery">jQuery</a>) was incredibly cool. I've had a few requests from users wondering how this release came about. While I can't speak for the other projects, I can, at least, speak for what happened with jQuery.</p>
	<p>Dion and I had been discussing solutions for providing better hosting solutions to JavaScript libraries for a long time (at least a year or two). Progress kept getting stalled at different points but persevered and got the release up at Google. I'm really glad to see this come about and I'm sure that jQuery users will certainly appreciate this release.</p>
	<p>I have a couple points of concern with the release, namely:</p>
	<ul>
	<li>How do we push a new release out? Currently we have to contact the guys at Google to get it pushed through - a way to automate this and do it programatically would be greatly appreciated (we could integrate it right into our release scripts).</li>
	<li>How do new pieces of code get added? There's no way for other projects to get added to the repository - some sort of process for joining would be ideal.</li>
	<li>SSL? Having an SSL-based CDN would be very useful, as well. However I suspect that if a site is going so far as to have SSL on their pages then they're probably not pulling their source code from an external site.</li>
	</ul>
	<p>Other than that, though, I'm quite pleased with the release. The more that people pull from there the faster it'll be for everyone who uses JavaScript libraries (cutting away that initial download time).
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5621" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/325158728" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/jquery-plugins-size-and-storage/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fjquery-plugins-size-and-storage%2F</feedburner:awareness></item>
		<item>
		<title>eval() Kerfuffle</title>
		<link>http://ejohn.org/blog/eval-kerfuffle/</link>
		<comments>http://ejohn.org/blog/eval-kerfuffle/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 14:09:59 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>firefox</category>
                <category>mozilla</category>
                <category>javascript</category>
                <category>links</category>
		<guid>http://ejohn.org/blog/eval-kerfuffle/</guid>
		<description><![CDATA[Last week it came out that, in Firefox (and other Gecko-based browsers) you could dip into the private scope of a function using eval, like so:

[js]// Getting "private" variables
var obj = (function() {
  var a = 21;
  return {
    // public function must reference 'a'
    fn: function() [...]]]></description>
			<content:encoded><![CDATA[	<p>Last week it <a href="http://peter.michaux.ca/article/8069">came out</a> that, in Firefox (and other Gecko-based browsers) you could dip into the private scope of a function using eval, like so:</p>
	<div class="syntax_hilite">
<div id="js-2">
	<div><span style="color: #009900; font-style: italic;">// Getting &quot;private&quot; variables</span><br />
<span style="color: #003366; font-weight: bold;">var</span> obj = <span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> a = <span style="color: #CC0000;">21</span>;<br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// public function must reference 'a'</span><br />
&nbsp; &nbsp; fn: <span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span>a;<span style="color:#008800; font-weight:bold;">&#125;</span><br />
&nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p><span style="color: #003366; font-weight: bold;">var</span> foo;<br />
<span style="color: #000066; font-weight: bold;">eval</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">'foo=a'</span>, obj.<span style="color: #006600;">fn</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
console.<span style="color: #006600;">log</span><span style="color:#008800; font-weight:bold;">&#40;</span>foo<span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color: #009900; font-style: italic;">// 21 </span><br />
&nbsp;</div>
	</div>
</div>
	<p>I think the common response to seeing the above was something like: WUH!?!?</p>
	<p>As can be seen in the <a href="http://ajaxian.com/archives/evalfooa-objfn-how-you-arent-private-in-firefox">ensuing</a> <a href="http://groups.google.com/group/google-caja-discuss/browse_thread/thread/3e5002e45f1b8f13/ead8d8597a22c013?#ead8d8597a22c013">discussions</a>.</p>
	<p>Perhaps more interestingly is the dig in to try and figure out how on earth this feature made it in to the language to being with. Brendan Eich provides some insight:</p>
	<blockquote><p><a href="http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/js/src/jsobj.c&#038;rev=3.2&#038;mark=580-590">3.2 &lt;fur> 1998-04-23 17:30</a>: Initial checkin of JavaScript 1.3, migrated from JSFUN13_BRANCH in /m/ src repository</p>
	<p>This eval extension, if memory serves (I was in mozilla.org at the time, not in the JS group at Netscape) originated in conversations with Microsoft's rep during ECMA-262 standardization, trying to reach agreement on a way to eval in other scopes.</p></blockquote>
	<p>At this point, however, it's pretty safe to say that since so few people know about it, and that (hopefully) there are no important sites relying upon its behavior, it can be stricken from the record.</p>
	<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=442333">Which it has been.</a></p>
	<p>It's been a crazy ride but you can expect to see this feature gone in Firefox 3.1 (the next release of Firefox, set to debut this year).
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5620" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/325123353" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/eval-kerfuffle/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Feval-kerfuffle%2F</feedburner:awareness></item>
		<item>
		<title>Powering a Web Revolution</title>
		<link>http://ejohn.org/blog/powering-a-web-revolution/</link>
		<comments>http://ejohn.org/blog/powering-a-web-revolution/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 09:44:05 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>development</category>
                <category>firefox</category>
                <category>firebug</category>
                <category>javascript</category>
                <category>css</category>
                <category>programming</category>
		<guid>http://ejohn.org/blog/powering-a-web-revolution/</guid>
		<description><![CDATA[Like every web developer I've spent a lot of time using the Firebug extension to Firefox in my day-to-day development. I've found it interesting to see how my development methodologies have changed with access to that tool.

Unsurprisingly, my personal development style mirrors much of the general web dev public. But what I find most interesting [...]]]></description>
			<content:encoded><![CDATA[	<p>Like every web developer I've spent a lot of time using the Firebug extension to Firefox in my day-to-day development. I've found it interesting to see how my development methodologies have changed with access to that tool.</p>
	<p>Unsurprisingly, my personal development style mirrors much of the general web dev public. But what I find most interesting is to try and track trends in web development that Firebug has single-handedly revolutionized.</p>
	<h2>Firebug Advances</h2>
	<p><b>Performance Profiling</b></p>
	<p>Prior to Firebug there was only rudimentary analysis of JavaScript performance (using tricks like injecting timers and computing the difference). Firebug brought us the ability to analyze all function calls during a period of execution, see how they each affected each other and, probably most important, see the difference in the sub-millisecond range.</p>
	<p>Previously none of these techniques were possible with pure-JavaScript techniques - having the ability to tap into the JavaScript engine (which Firebug does) is fundamentally important to getting good analysis.</p>
	<p>You can see an immediate interest, by JavaScript library authors, in the performance of their code bases around the time of Firebug's introduction of profiling.</p>
	<p><b>Console logging with object introspection</b></p>
	<p>Logging statements has always been possible with JavaScript (and, most infamously, with the <code>alert()</code> function) however Firebug gave us something significant: The ability to click and introspect into logged objects. This includes the ability to click DOM nodes (and see their properties and methods) and even normal objects (like Arrays or Object literals).</p>
	<p>Firebug has to maintain a lot references to point to where these objects exist - and it wouldn't be possible in pure-JavaScript without introducing an excessive number of memory leaks.</p>
	<p><b>Current Styles / CSS Rules</b></p>
	<p>There had existed some tools for examining the current CSS style values of a DOM element (such as its dimensions and positioning) but Firebug brought a whole new level of inspection: The ability to see which stylesheet rules were introducing specific styling on an element. Not to mention the ability to edit the rules in-line (along with disabling them outright).</p>
	<p>This level of inspection completely overhauled Web Design - and has been able to detach many web designers from their IDE-of-choice into a more agnostic view of CSS design. Absolutely the biggest short-coming of this feature is its inability to work cross-browser (although, that argument can certainly be used for most Firebug features).</p>
	<p><b>Network Performance</b></p>
	<p>Firebug's network tab gave developers the ability to see - in very real terms - two things: 1) How long a resource was taking to load and 2) How the loading of that resource was blocking the loading of other resources. #2 is especially important, seeing that the execution of JavaScript blocks other actions from occurring can be an eye-opening experience to most developers. Or even seeing how a slow-loading stat tracking script can prevent the further display of the page.</p>
	<p><b>XMLHttpRequest Inspection</b></p>
	<p>While XMLHttpRequest use existed prior to the existence of Firebug it was horribly hard to debug - it was rarely obvious where errors were occurring - on the client-side? on the server-side? in the transmission? The ability to see how the requests occurred - and very importantly - how long they took (and even how frequently they occurred!) has done much to improve the overall quality of Ajax use on web pages.</p>
	<p><b>JavaScript Debugging</b></p>
	<p>I would've said that JavaScript Debugging was a piece of that equation, as well, however <a href="http://www.mozilla.org/projects/venkman/">Venkman</a> definitely lead the way, in that respect (and has been a de-facto debugger for quite some time).</p>
	<p>I'd argue that these trends wouldn't be where they are right now if it weren't for Firebug - and that tools are the primary reason for a development strategy's success. As a corollary look at the relative success of web standards - I'd argue that adherence to HTML or CSS wouldn't be where it is today without the tools to verify a page's compliance.</p>
	<h2>How to Improve</h2>
	<p>The question now becomes: What are the next set of tools that Firebug can introduce that will revolutionize its respective areas of development?</p>
	<p>I'd like to propose a couple, possible, areas of interest:</p>
	<p><b>JavaScript Library Analysis</b></p>
	<p>As it stands Firebug's JavaScript function analysis is, perhaps, too finely-grained to provide help in many instances - especially when the use of JavaScript libraries is at play. For example, when using jQuery, you're generally more concerned with finding out how fast, or slow, a particular method is - or a selector - not the performance of all the individual internal methods of jQuery.</p>
	<p>I began some of this analysis with my <a href="http://ejohn.org/blog/deep-profiling-jquery-apps/">Deep Profiling jQuery Apps</a> experiment but that's really only a test. Smart integration of JavaScript library knowledge into Firebug can provide significant details about how your code should be performing.</p>
	<p><b>Visual Performance Profiling</b></p>
	<p>Application performance profiling is rather clumsy right now, we have a number of disparate resources (network performance, rendering performance, script performance) that we need to mentally merge to create a full picture of what's happening. To counter this I'd like to propose a way of visually viewing how components of a site affect its overall performance. Perhaps a way to break things down like this:</p>
	<ul>
	<li>Header: 300ms: 20ms Transmission + 20ms Parsing + 60ms CSS + 200ms JavaScript</li>
	<li>Google Ad: [BLOCKING RENDERING] 600ms: 20ms Transmission + 20ms Parsing + 20ms CSS + 240ms JavaScript + 300ms Frame Loading</li>
	<li>Sidebar: 400ms: 40ms Transmission + 40ms Parsing + 80ms CSS + 240ms JavaScript</li>
	</ul>
	<p>The <a href="http://developer.yahoo.com/yslow/">YSlow</a> Firebug plugin already provides some level of analysis on your site - but it's much more holistic (giving you generic tips for files and pieces of code). Whereas a more specific approach would be greatly appreciated.</p>
	<p><b>Ajax Improvements</b></p>
	<p>We currently have the ability to view XMLHttpRequests as they occur, which is great, but some additions could be made that would serve to be quite helpful, such as:</p>
	<ul>
	<li>The ability to manipulate a request and re-submit it. If you're attempting to see how different inputs will affect your site, this would be a great way to play back requests or see how they can be best improved.</li>
	<li>Right now Firebug only lets you know the basic textual output that's coming from the server-side. Having it be able to tell you if incoming XML, JSON, or even HTML is syntactically correct (and even being able to navigate the resulting structures - as the browser would see them) would be a huge boon. As it stands it can be quite frustrating to receive a slightly-malformed response from a server and be stuck trying to figure out what's going wrong.</li>
	<li>Better JSON/JSONP integration is essential. There are a large number of Ajax requests being done through dynamic script tag injection - and those are completely unmonitored by Firebug's XMLHttpRequest tracking. Being able to see what requests and responses look like - and where errors may be occurring - would be immensely useful.</li>
	</ul>
	<p><b>Rendering Performance Analysis</b></p>
	<p>While we have fantastic tools for digging in to the performance of JavaScript - CSS is a complete unknown. How much overhead do our stylesheets provide? How many elements does this CSS rule affect? Does this rule cause a costly reflow to occur? and how many times? How long does it take to render a particular portion of a page? Would changing the structure of my page help to improved perceived rendering speed?</p>
	<p>Virtually all of these questions are un-answered and we need a tool to help provide a solid response.</p>
	<p><b>Security Analysis</b></p>
	<p>Security is one area that has seen virtually no attention in the respect of user tools. Most developers have no idea how secure their web site is or how vulnerable it may be to attacks. There needs to be easily-accessible tools for testing:</p>
	<ul>
	<li>SQL Injection attacks</li>
	<li>XSS Injection</li>
	<li>Susceptibility to Spoofing (Data Encryption)</li>
	</ul>
	<p>At the very least. The problem here is that while these tools will be incredibly useful for developers to improve their web sites - it'll also encourage malicious behavior. Although, arguably, those that wish to be malicious already have the tools to do so.</p>
	<p><b>Standards Integration</b></p>
	<p>Inline support for analyzing the standards-compliance of a page. Being able to see notes next to specific elements, attributes, CSS rules, etc. that show information on how they don't comply with particular standards - or even how they could be improved to match standards.</p>
	<p>This includes inline strictness warnings for JavaScript (produced by the JavaScript engine).</p>
	<p>I think that compliance should go a step further, as well, and look to provide information on Microformat and RDFa compliance - pointing out specific errors and helping sites to become better formatted.</p>
	<p>Finally - RSS and Atom standards compliance. Notifying a developer that their site's RSS/Atom feed is malformed would allow them to immediately make a more compliant feed (a common area of mistakes).</p>
	<p><b>Internet Explorer Support</b></p>
	<p>The final, and perhaps most difficult, item that should occur would be a port of Firebug over to Internet Explorer. Both Safari and Opera have web developer tools integrated into their browsers - however Internet Explorer still consumes a majority market share and there's no good tools in sight. (I, personally, use <a href="http://www.my-debugbar.com/wiki/CompanionJS/HomePage">CompanionJS</a> but it's still a far cry from the full suite of utilities that Firebug provides - especially in the realm of DOM/CSS.)</p>
	<p>This could probably be remedied if there was a really good pure-JavaScript Firebug (although the overhead associated with many of Firebug's features would lead to an astronomically-sized implementation). The current "Firebug Lite" is something of a joke - only vaguely functioning in modern browsers.</p>
	<hr/>
	<p>Not only do I want to see Firebug improve - it's imperative that Firebug continue to improve, for the sake of web developers everywhere. If it simply stalls and works into a stasis of bug fixes then web developers will be stuck with the current set of tools for quite some time. While other browsers are improving at a rapid pace, it'll still be quite some time before they are able to match the current feature-set of Firebug.</p>
	<p>Since so much of web development ecosystem is currently linked to the health of a single tool advances have to be made now and they have to be made quickly in order for the web to flourish and survive as a development medium.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5618" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/324098090" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/powering-a-web-revolution/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fpowering-a-web-revolution%2F</feedburner:awareness></item>
		<item>
		<title>Whoisi?</title>
		<link>http://ejohn.org/blog/whoisi/</link>
		<comments>http://ejohn.org/blog/whoisi/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 22:15:50 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>sites</category>
                <category>social</category>
		<guid>http://ejohn.org/blog/whoisi/</guid>
		<description><![CDATA[Good friend - and fellow Mozillian - Chris Blizzard has just released a long-time "hack in the evenings" project of his: Whoisi. I think the best "one line" description that I've heard for it, thus far is "a wiki-like Friendfeed." It's quite fun - sort of an identity service combined with a wiki combined with [...]]]></description>
			<content:encoded><![CDATA[	<p>Good friend - and fellow Mozillian - <a href="http://www.0xdeadbeef.com/">Chris Blizzard</a> has just released a long-time "hack in the evenings" project of his: <a href="http://whoisi.com/">Whoisi</a>. I think the best "one line" description that I've heard for it, thus far is "a wiki-like Friendfeed." It's quite fun - sort of an identity service combined with a wiki combined with a feed reader. All without requiring any form of signing up or logging in. It'll be fun to see how it all comes out in the wash, but for now it's certainly grabbing the attention of some <a href="http://www.scripting.com/stories/2008/06/26/whatIsWhoisicom.html">notable</a> <a href="http://twitter.com/laughingsquid/statuses/844529972">people</a>.</p>
	<p>Chris has posted a <a href="http://www.0xdeadbeef.com/weblog/?p=348">ton of details</a> concerning how the application works. I've had the opportunity to follow his development for a while now and heard about all the interesting issues that he's tackled - related to Python, databases, scaling, and jQuery. I love seeing "for fun" applications finally come to light - and this one is a keeper.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5617" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/321012926" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/whoisi/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fwhoisi%2F</feedburner:awareness></item>
		<item>
		<title>New CSS in Firefox 3</title>
		<link>http://ejohn.org/blog/new-css-in-firefox-3/</link>
		<comments>http://ejohn.org/blog/new-css-in-firefox-3/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 16:54:14 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>firefox</category>
                <category>mozilla</category>
                <category>css</category>
                <category>links</category>
		<guid>http://ejohn.org/blog/new-css-in-firefox-3/</guid>
		<description><![CDATA[Visit: New CSS Features in Firefox 3

David Baron, a Mozilla developer, has a write-up on the new CSS features that are available in Firefox 3. There's a mix of additions - everything from CSS 2.0 and 2.1 features to new additions that are tracking CSS 3.

Some of my favorite additions include:

The CSS 3 Box Specification [...]]]></description>
			<content:encoded><![CDATA[	<p><b>Visit:</b> <a href="http://dbaron.org/log/20080613-firefox3-css">New CSS Features in Firefox 3</a></p>
	<p><a href="http://dbaron.org/">David Baron</a>, a Mozilla developer, has a write-up on the new CSS features that are available in Firefox 3. There's a mix of additions - everything from CSS 2.0 and 2.1 features to new additions that are tracking CSS 3.</p>
	<p>Some of my favorite additions include:</p>
	<p><b>The <a href="http://lists.w3.org/Archives/Public/www-style/2007Nov/0119.html">CSS 3 Box Specification</a></b> (in the form of -moz-max-content, -moz-min-content, -moz-fit-content, and -moz-available values to width, min-width, and max-width). </li>
	<blockquote><p>-moz-fit-content actually does let authors do some things that previously weren't possible without tables, such as putting a background on headings that doesn't fill the whole width of the container unless the heading does, but is a single rectangle if the heading breaks to multiple lines (see <a href="http://dbaron.org/log/20080613-firefox3-css-examples/width-fit-content">Demo</a>).</p></blockquote>
	<p><b>Wrapped whitespace</b> (white-space: pre-wrap). This allows you to have a &lt;pre/> whose contents are wrapped nicely, while still maintaining its rigid structure.</p>
	<p><center.<img src="http://dbaron.org/log/20080613-firefox3-css-examples/pre-wrap-narrow"/></center></p>
	<p><b>rgba() values.</b> You can now apply opacity directly to background colors (as opposed to having to create a shim div/span and styling that instead). Note that the below text is fully opaque.</p>
	<div class="syntax_hilite">
<div id="css-3">
	<div>body <span style="color:#008800; font-weight:bold;">&#123;</span> <span style="color:#CC0033; font-weight: bold;">background</span>: <span style="color:#CC0099;">url</span><span style="color:#008800; font-weight:bold;">&#40;</span>stripes-<span style="color: #800000;">6</span><span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
div <span style="color:#008800; font-weight:bold;">&#123;</span> <span style="color:#CC0033; font-weight: bold;">background</span>: rgba<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #800000;">0</span>, <span style="color: #800000;">255</span>, <span style="color: #800000;">0</span>, <span style="color: #800000;">0</span>.<span style="color: #800000;">5</span><span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
h2 <span style="color:#008800; font-weight:bold;">&#123;</span> <span style="color:#CC0033; font-weight: bold;">background</span>: rgba<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #800000;">255</span>, <span style="color: #800000;">0</span>, <span style="color: #800000;">0</span>, <span style="color: #800000;">0</span>.<span style="color: #800000;">5</span><span style="color:#008800; font-weight:bold;">&#41;</span>; <span style="color:#008800; font-weight:bold;">&#125;</span></div>
	</div>
</div>
	<p><img src="http://dbaron.org/log/20080613-firefox3-css-examples/alpha-3-screenshot"/></p>
	<p><b>inline-block and inline-table</b> Such a powerful addition - and one that now brings Firefox in line with most other browsers. It'll allow you to create much-more-complicated layouts that were previously very trying to implement using normal CSS. <a href="http://dbaron.org/log/20080613-firefox3-css-examples/display-inline-block-and-table">Demo</a>.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5615" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/320023977" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/new-css-in-firefox-3/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fnew-css-in-firefox-3%2F</feedburner:awareness></item>
		<item>
		<title>Meet PPK (Creator of Quirksmode.org)</title>
		<link>http://ejohn.org/blog/meet-ppk-creator-of-quirksmodeorg/</link>
		<comments>http://ejohn.org/blog/meet-ppk-creator-of-quirksmodeorg/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:04:59 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>boston</category>
                <category>javascript</category>
                <category>meetup</category>
		<guid>http://ejohn.org/blog/meet-ppk-creator-of-quirksmodeorg/</guid>
		<description><![CDATA[Kind of last moment but I just got word that PPK (the creator of the excellent Quirksmode.org) is in Boston and looking to meet up with local developers. If you're interested we'll be at The Pour House at about 7pm (today, June 25th) and you're welcome! If you're coming please reply to this email or [...]]]></description>
			<content:encoded><![CDATA[	<p>Kind of last moment but I just got word that PPK (the creator of the excellent <a href="http://www.quirksmode.org/">Quirksmode.org</a>) is in Boston and looking to meet up with local developers. If you're interested we'll be at <a href="http://www.yelp.com/biz/the-pour-house-boston">The Pour House</a> at about 7pm (today, June 25th) and you're welcome! If you're coming please reply to this email or <a href="http://ejohn.org/about/">give me a call</a> so that I can spot you.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5614" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/319959500" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/meet-ppk-creator-of-quirksmodeorg/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fmeet-ppk-creator-of-quirksmodeorg%2F</feedburner:awareness></item>
		<item>
		<title>Twitter Quick Reply</title>
		<link>http://ejohn.org/blog/twitter-quick-reply/</link>
		<comments>http://ejohn.org/blog/twitter-quick-reply/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 16:12:31 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>twitter</category>
                <category>javascript</category>
		<guid>http://ejohn.org/blog/twitter-quick-reply/</guid>
		<description><![CDATA[A quick bookmarklet that I made for Asa Dotzler. If you've ever visited a tweet, on Twitter, directly, and had wished to immediately reply to its author you probably found it to be quite convoluted (typically this is the case if you subscribe to services like Summize or Tweetscan. It usually involves copying the username, [...]]]></description>
			<content:encoded><![CDATA[	<p>A quick bookmarklet that I made for <a href="http://weblogs.mozillazine.org/asa/">Asa Dotzler</a>. If you've ever visited a tweet, on Twitter, directly, and had wished to immediately reply to its author you probably found it to be quite convoluted (typically this is the case if you subscribe to services like <a href="http://summize.com/">Summize</a> or <a href="http://tweetscan.com/">Tweetscan</a>. It usually involves copying the username, visiting the reply screen, and then typing/pasting in the relevant parts to make the @reply. Instead you can just use the following bookmarklet to make that easy.</p>
	<div class="syntax_hilite">
<div id="js-4">
	<div>javascript:window.<span style="color: #006600;">location</span>=window.<span style="color: #006600;">location</span>.<span style="color: #006600;">href</span>.<span style="color: #006600;">replace</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #0066FF;">/<span style="color:#008800; font-weight:bold;">&#40;</span>com.<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#91;</span>^.\/<span style="color:#008800; font-weight:bold;">&#93;</span>+<span style="color:#008800; font-weight:bold;">&#41;</span>.*/</span>,<span style="color: #3366CC;">"$1home?status=@$2+"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>First, Drag this to your bookmark bar:</b> <a href='javascript:window.location=window.location.href.replace(/(com.)([^.\/]+).*/,"$1home?status=@$2+");'>Twitter Reply</a></p>
	<p><b>Second, visit a tweet:</b> <a href="http://twitter.com/jeresig/statuses/841204003">http://twitter.com/jeresig/statuses/841204003</a></p>
	<p>Then hit the bookmarklet and you should be taken to the reply screen with "@jeresig " (or whatever the appropriate username is) already pre-filled in. Enjoy!</p>
	<p>P.S. As a bonus it maintains the http/https URL protocol, as well.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5613" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/319177922" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/twitter-quick-reply/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Ftwitter-quick-reply%2F</feedburner:awareness></item>
		<item>
		<title>BBC Removing Microformat Support</title>
		<link>http://ejohn.org/blog/bbc-removing-microformat-support/</link>
		<comments>http://ejohn.org/blog/bbc-removing-microformat-support/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 22:03:57 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category />
		<guid>http://ejohn.org/blog/bbc-removing-microformat-support/</guid>
		<description><![CDATA[Visit: BBC Removing Microformat Support

After performing a number of usability studies (both on average users and users with screen readers) the BBC found that using the Microformat convention of &lt;abbr title="...">...&lt;/abbr> to denote items like dates negatively impacted usability. This is a huge blow to the Microformats community. While this concern has been discussed for [...]]]></description>
			<content:encoded><![CDATA[	<p><b>Visit:</b> <a href="http://www.bbc.co.uk/blogs/radiolabs/2008/06/removing_microformats_from_bbc.shtml">BBC Removing Microformat Support</a></p>
	<p>After performing a number of usability studies (both on average users and users with screen readers) the <a href="http://www.bbc.co.uk/blogs/radiolabs/2008/06/removing_microformats_from_bbc.shtml">BBC found</a> that using the Microformat convention of <code>&lt;abbr title="...">...&lt;/abbr></code> to denote items like dates negatively impacted usability. This is a huge blow to the Microformats community. While this concern has been <a href="http://www.webstandards.org/2007/04/27/haccessibility/">discussed for a while</a> this is the first instance of a major corporation reneging on their previous Microformat commitment.</p>
	<p>As an alternative the BBC seems to be examining <a href="http://www.w3.org/TR/rdfa-syntax/">RDFa</a> - one of the leading "competitors" in the "embed machine-readable data in (X)HTML markup" space. Examining the basic <a href="http://www.w3.org/TR/xhtml-rdfa-primer/">RDFa-in-XHTML</a> primer it's obvious that RDFa still has a long ways to go before any sort of practical adoption by developers and designers. Riddled with advanced, or just plain confusing, terminology (XML namespaces, Dublin Core, semantic web, and not to mention the addition of many new attributes - like typeof, about, and property) it appears to be solidly entrenched in the ways that Microformats were able to shake themselves free of, allowing them to achieve widespread adoption.</p>
	<p>It's pretty obvious that the Microformats community is going to have to step up and prevent any sort of attrition that will occur in this situation.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5612" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/318564620" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/bbc-removing-microformat-support/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fbbc-removing-microformat-support%2F</feedburner:awareness></item>
		<item>
		<title>Simple Extensions in Firefox 3</title>
		<link>http://ejohn.org/blog/simple-extensions-in-firefox-3/</link>
		<comments>http://ejohn.org/blog/simple-extensions-in-firefox-3/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 21:43:29 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>extensions</category>
                <category>firefox</category>
                <category>mozilla</category>
                <category>javascript</category>
		<guid>http://ejohn.org/blog/simple-extensions-in-firefox-3/</guid>
		<description><![CDATA[It was fascinating to watch the unveiling of Firefox 3 last week. I'm pleased that, in some small way, my contributions helped to bring this browser out the door.



First 24 hours: 8.3 million downloads, 69 downloads/second, 20 Gb/s Peak Transfer

While I generally focus on issues tangential to JavaScript code, at Mozilla - like testing, performance [...]]]></description>
			<content:encoded><![CDATA[	<p>It was fascinating to watch the unveiling of <a href="http://mozilla.com/">Firefox 3</a> last week. I'm pleased that, in some small way, my contributions helped to bring this browser out the door.</p>
	<p><center><a href="http://www.flickr.com/photos/jeresig/2590008041/" title="Firefox 3: Download Day Results by John Resig, on Flickr"><img src="http://farm4.static.flickr.com/3091/2590008041_2a3a61983d_m.jpg" width="240" height="140" alt="Firefox 3: Download Day Results" /></a></p>
	<p>First 24 hours: 8.3 million downloads, 69 downloads/second, 20 Gb/s Peak Transfer</center></p>
	<p>While I generally focus on issues tangential to JavaScript code, at Mozilla - like testing, performance analysis, specifications, standards, bug hunting, speaking, demos, and blogging - some of my code is live within the browser, and that makes me quite happy.</p>
	<p>One of my <a href="http://ejohn.org/blog/fueling-the-firefox/">first tasks at Mozilla</a> was to, with <a href="http://starkravingfinkle.org/">Mark Finkle</a>, develop a JavaScript API for performing common interactions typically desired by extension developers, called: <a href="http://wiki.mozilla.org/FUEL">FUEL</a>. This is a pure-JavaScript implementation that sits as a proxy inbetween the developer and the various, traditional, XPCOM-style ways of performing actions.</p>
	<p>If you're interested in learning more about FUEL I've collected a number of links and examples:</p>
	<p><b>The Development of FUEL</b></p>
	<p>FUEL was created over the course of a couple months, in early 2007, by <a href="http://starkravingfinkle.org/">Mark Finkle</a> and I. Mark had much-better knowledge of Mozilla's APIs and I had good knowledge of JavaScript and API design - the match worked out nicely. I've written <a href="http://ejohn.org/blog/fueling-the-firefox/">a couple</a> <a href="http://ejohn.org/blog/fuel-02-progress/">blog posts</a> on FUEL and <a href="http://starkravingfinkle.org/blog/2007/01/extension-development-with-fuel/">so</a> <a href="http://starkravingfinkle.org/blog/2007/02/fuel-project-status/">has</a> <a href="http://starkravingfinkle.org/blog/2007/04/fuel-project-status-01-lands/">Mark</a>.</p>
	<p>You can also see the features and code that went into <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=372069">FUEL 0.1</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=380168">FUEL 0.2</a> in Bugzilla.</p>
	<p><b>FUEL, Today</b></p>
	<p>Today FUEL lives in Firefox 3 (meaning that you can use it to develop Firefox extensions) and is part of the core Mozilla platform (meaning that portions of the API will be available in any Mozilla-based application that is built). For example you can even use a FUEL-like API in Thunderbird (called '<a href="http://clarkbw.net/blog/2008/03/20/blue-steel/">STEEL</a>'). Here are some of the best resources for getting started with FUEL in Firefox 3:</p>
	<ul>
	<li><a href="http://wiki.mozilla.org/FUEL">FUEL - Main Page</a> (API, Examples)</li>
	<li><a href="http://developer.mozilla.org/en/docs/FUEL">FUEL - Documentation</a> (API)</li>
	<li><a href="http://www.slideshare.net/jeresig/fuel-firefox-3-june-07">FUEL - Presentation (John Resig)</a> - Given in Paris at a Mozilla DevDay, June 2007 - see below.</li>
	<li><a href="http://starkravingfinkle.org/blog/2007/06/tokyo-developer-conference-fuel-xulrunner/">FUEL - Presentation (Mark Finkle)</a> - Given in Tokyo at a Mozilla DevDay, June 2007.</li>
	<li><a href="http://clarkbw.net/blog/2008/04/04/extending-bugzilla-links-in-thunderbird/">STEEL - Example</a> - If you're interested in extending Thunderbird Bryan Clark provides a good example.</li>
	</ul>
	<p><center><br />
<div style="width:425px;text-align:left" id="__ss_76364"><object style="margin:0px" width="425" height="355"><br />
<param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=fuel-firefox-3-june-073964"/>
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=fuel-firefox-3-june-073964" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
</center></p>
	<p>Here are some of my favorite example of FUEL in action. It was very important to me that the most-common actions take no more than a single line of code to perform - with even complex actions keeping nice and trim.</p>
	<p><b>Open, and activate, a new tab pointing to Google.com</b></p>
	<div class="syntax_hilite">
<div id="js-5">
	<div>Application.<span style="color: #006600;">browser</span>.<span style="color: #006600;">open</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"http://google.com/"</span><span style="color:#008800; font-weight:bold;">&#41;</span>.<span style="color: #006600;">active</span> = <span style="color: #003366; font-weight: bold;">true</span>;</div>
	</div>
</div>
	<p><b>Close the active browser tab</b></p>
	<div class="syntax_hilite">
<div id="js-6">
	<div>Application.<span style="color: #006600;">browser</span>.<span style="color: #006600;">activeTab</span>.<span style="color: #006600;">close</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>Close all tabs that mention Google</b></p>
	<div class="syntax_hilite">
<div id="js-7">
	<div>Application.<span style="color: #006600;">browser</span>.<span style="color: #006600;">tabs</span>.<span style="color: #006600;">forEach</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span>tab<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#008800; font-weight:bold;">&#40;</span> tab.<span style="color: #006600;">url</span>.<span style="color: #006600;">match</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #0066FF;">/google/</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; tab.<span style="color: #006600;">remove</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>Add a new bookmark pointing to Mozilla</b></p>
	<div class="syntax_hilite">
<div id="js-8">
	<div>Application.<span style="color: #006600;">bookmarks</span>.<span style="color: #006600;">add</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"Mozilla"</span>, <span style="color: #3366CC;">"http://mozilla.org/"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>Remove all bookmarks pointing to Google.com</b></p>
	<div class="syntax_hilite">
<div id="js-9">
	<div>Application.<span style="color: #006600;">bookmarks</span>.<span style="color: #006600;">all</span>.<span style="color: #006600;">forEach</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color:#008800; font-weight:bold;">&#40;</span>cur<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color:#008800; font-weight:bold;">&#40;</span> cur.<span style="color: #006600;">url</span>.<span style="color: #006600;">match</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #0066FF;">/google.<span style="color: #006600;">com</span>/</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; cur.<span style="color: #006600;">remove</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>FUEL, Future</b></p>
	<p>Development is still going strong on FUEL. There's a Google Summer of Code student <a href="http://starkravingfinkle.org/blog/2008/05/fuel-and-google-soc/">working on extending the API</a> and porting it to more parts of the platform (along with backwards support for Firefox 2!). We'll probably end up seeing this in Firefox 3.1 (the next version of Firefox, due out later this year).</p>
	<p>If you have any questions concerning how to use FUEL, or to develop Firefox extensions in general, your best bet would probably be to join the #extdev IRC channel on irc.mozilla.org. Lots of knowledgeable people hang out there and will be more-than-capable of answering any questions that you might have.</p>
	<p>Once again, I'm terribly excited by the final release of Firefox 3 - here's hoping to many more excellent releases to come!
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5611" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/318554291" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/simple-extensions-in-firefox-3/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fsimple-extensions-in-firefox-3%2F</feedburner:awareness></item>
		<item>
		<title>Deep Profiling jQuery Apps</title>
		<link>http://ejohn.org/blog/deep-profiling-jquery-apps/</link>
		<comments>http://ejohn.org/blog/deep-profiling-jquery-apps/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 01:00:08 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>performance</category>
                <category>javascript</category>
                <category>jquery</category>
		<guid>http://ejohn.org/blog/deep-profiling-jquery-apps/</guid>
		<description><![CDATA[This evening I was playing around with the idea of profiling jQuery applications - trying to find a convenient way to completely analyze all the code that is being executed in your application.

I've come up with a plugin that you can inject into a jQuery site that you own and see how the performance breaks [...]]]></description>
			<content:encoded><![CDATA[	<p>This evening I was playing around with the idea of profiling jQuery applications - trying to find a convenient way to completely analyze all the code that is being executed in your application.</p>
	<p>I've come up with <a href="http://dev.jquery.com/~john/plugins/profile/jquery-profile.js">a plugin</a> that you can inject into a jQuery site that you own and see how the performance breaks down method-by-method.</p>
	<p>Here's how you can try this plugin on your own site:</p>
	<p><b>Step 1: Copy site HTML, add base href, add plugin.</b></p>
	<p>For example, <a href="http://github.com/">Github.com</a> uses jQuery for a few basic effects and pieces of interaction (they use considerably more on pages beyond the homepage).</p>
	<p>I took a copy of their page, added a &lt;base href&gt; to the top and injected the <a href="http://dev.jquery.com/~john/plugins/profile/jquery-profile.js">profiling plugin</a> giving a <a href="http://dev.jquery.com/~john/plugins/profile/github.com.html">resulting test page</a>.</p>
	<p>Before:</p>
	<div class="syntax_hilite">
<div id="html-10">
	<div>&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"content-type"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"text/html;charset=UTF-8"</span> /<a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"/javascripts/bundle.js"</span><a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span><br />
&nbsp; &nbsp; ...<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div>
	</div>
</div>
	<p>After:</p>
	<div class="syntax_hilite">
<div id="html-11">
	<div>&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"content-type"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"text/html;charset=UTF-8"</span> /<a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/base.html"><span style="color: #000000; font-weight: bold;">&lt;base</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://github.com/"</span>/<a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"/javascripts/bundle.js"</span><a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"http://dev.jquery.com/~john/plugins/profile/jquery-profile.js"</span><a href="http://december.com/html/4/element/.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span><br />
&nbsp; &nbsp; ...<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div>
	</div>
</div>
	<p><b>Step 2: Use the site normally.</b></p>
	<p>Use the site as you normally would. Load it up, click around - perform normal interactions. In the case of the Github.com page I let it load, scrolled down, and clicked on one of the demo images - which caused an overlay to appear. I then closed the X on the overlay and let it hide.</p>
	<p><b>Step 3: View data.</b></p>
	<p>In your console type <code>jQuery.displayProfile();</code> and scroll down to the bottom of the page. You should see something like the following:</p>
	<p><center><a href="http://ejohn.org/files/jquery-profile.png"><img src="http://ejohn.org/files/jquery-profile.sm.png"/></a></center></p>
	<p>and here's a sample data dump:</p>
	<div style="text-align: left;font-size:10px;"><big><b>Event: ready (165ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery(#document)</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.bind("ready", function())</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>3.6%</td>
	<td>6</td>
	<td>jQuery("a[hotkey]")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.each(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery(#document)</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.bind("keydown.hotkey", function())</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("#triangle")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("body")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>1.2%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.append("&lt;div id="triangle" style="position: absolute; display: none;"&gt; &lt;/div&gt;")</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.6%</td>
	<td>1</td>
	<td>jQuery("#repo_menu .active")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>3.6%</td>
	<td>6</td>
	<td>jQuery(".jshide")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.hide()</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>1.2%</td>
	<td>2</td>
	<td>jQuery(".toggle_link")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.click(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.6%</td>
	<td>1</td>
	<td>jQuery("#beta :text")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.focus(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.6%</td>
	<td>1</td>
	<td>jQuery("#beta form")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.ajaxForm(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>1.2%</td>
	<td>2</td>
	<td>jQuery(".hide_alert")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.click(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("#login_field")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.focus()</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("#versions_select")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.change(function())</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>1.2%</td>
	<td>2</td>
	<td>jQuery("a[rel*=facebox]")</td>
	<td></td>
	<td>3</td>
</tr>
	<tr>
<td>17.6%</td>
	<td>29</td>
	<td>&nbsp;&nbsp;.facebox()</td>
	<td>3</td>
	<td>3</td>
</tr>
</tbody>
</table>
<big><b>Event: load (1ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
</tbody>
</table>
<big><b>Event: click (29ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>jQuery("#facebox .loading")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>jQuery("facebox_overlay")</td>
	<td></td>
	<td></td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>jQuery("body")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.append("&lt;div id="facebox_overlay" class="facebox_hide"&gt;&lt;/div&gt;")</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("#facebox_overlay")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.hide()</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>&nbsp;&nbsp;.addClass("facebox_overlayBG")</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.css("opacity", 0)</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>&nbsp;&nbsp;.click(function())</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.fadeIn(200)</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>jQuery("#facebox .content")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>&nbsp;&nbsp;.empty()</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>jQuery("#facebox .body")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.children()</td>
	<td>1</td>
	<td>2</td>
</tr>
	<tr>
<td>10.3%</td>
	<td>3</td>
	<td>&nbsp;&nbsp;.hide()</td>
	<td>2</td>
	<td>2</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.end()</td>
	<td>2</td>
	<td>1</td>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.append("&lt;div class="loading"&gt;&lt;img src="/facebox/loading.gif"/&gt;&lt;/div&gt;")</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery("#facebox")</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery({...})</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>&nbsp;&nbsp;.width()</td>
	<td>1</td>
	<td></td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.css({...})</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>6.9%</td>
	<td>2</td>
	<td>&nbsp;&nbsp;.show()</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery(#document)</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>&nbsp;&nbsp;.bind("keydown.facebox", function())</td>
	<td>1</td>
	<td>1</td>
</tr>
	<tr>
<td>0.0%</td>
	<td>0</td>
	<td>jQuery(#document)</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>3.4%</td>
	<td>1</td>
	<td>&nbsp;&nbsp;.trigger("loading.facebox")</td>
	<td>1</td>
	<td>1</td>
</tr>
</tbody>
</table>
<big><b>Event: beforeReveal.facebox (1ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
</tbody>
</table>
<big><b>Event: click (6ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
	<tr>
<td>16.7%</td>
	<td>1</td>
	<td>jQuery(#document)</td>
	<td></td>
	<td>1</td>
</tr>
	<tr>
<td>66.7%</td>
	<td>4</td>
	<td>&nbsp;&nbsp;.trigger("close.facebox")</td>
	<td>1</td>
	<td>1</td>
</tr>
</tbody>
</table>
<big><b>Event: close.facebox (3ms)</b></big><br />
<table>
<tbody>
<tr>
<th>%</th>
	<th>(ms)</th>
	<th>Method</th>
	<th>in</th>
	<th>out</th>
</tr>
</tbody>
</table>
</div>
	<p>This quick table of data should be able to provide you with some interesting information about what's happening in your code. The result is still incredibly basic (really only providing the most basic level of jQuery method introspection) but it definitely shows some merit.</p>
	<p>If you wish to create a different view for the data you can access the raw data structure by running <code>jQuery.getProfile();</code>.</p>
	<p>The next stage of development for this plugin would be to reveal which methods are running inside other jQuery methods - in addition to monitoring other aspects of the application (such as timers, Ajax callbacks, etc.). I'm pleased with even this most-basic result - it gives me the ability to quickly, and easily, learn much more about a jQuery-using application.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5609" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/312805492" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/deep-profiling-jquery-apps/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fdeep-profiling-jquery-apps%2F</feedburner:awareness></item>
		<item>
		<title>Spicing Up Embedded JavaScript</title>
		<link>http://ejohn.org/blog/spicing-up-embedded-javascript/</link>
		<comments>http://ejohn.org/blog/spicing-up-embedded-javascript/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 01:20:44 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>ruby</category>
                <category>java</category>
                <category>python</category>
                <category>php</category>
                <category>perl</category>
                <category>javascript</category>
		<guid>http://ejohn.org/blog/spicing-up-embedded-javascript/</guid>
		<description><![CDATA[One thing that I absolutely adore is the sheer embeddability of JavaScript. It's a (comparatively) simple language that is fiercely flexible. I tend to liken JavaScript to water - alone it's painfully simple but it can take the form of its container - and mixing it with anything enhances its flavor.

Since JavaScript, alone, is so [...]]]></description>
			<content:encoded><![CDATA[	<p>One thing that I absolutely adore is the sheer embeddability of JavaScript. It's a (comparatively) simple language that is fiercely flexible. I tend to liken JavaScript to water - alone it's painfully simple but it can take the form of its container - and mixing it with anything enhances its flavor.</p>
	<p>Since JavaScript, alone, is so dumb (we've become spoiled by browsers which provide DOM, setTimeout/setInterval, and even a global object reference - none of which are necessarily required my an ECMAScript implementation) we must rely upon the spice of 'larger' languages to help it gain some taste.</p>
	<p>We can start by taking a look at some of the most popular languages that are available today: Python, Perl, PHP, Ruby, and Java -- all of which have, at least, one embeddable JavaScript interpreter.</p>
	<p>One thing is the same in all the interpreter implementations, as well, they all have the ability to introduce (at least) simple objects into interpreter (from the parent language) and extract values again. Sometimes this may be as simple as executing a JavaScript function and getting its return value (which is often translated from its internal JavaScript form back into the native language).</p>
	<p>There's a couple points upon which I like to evaluate the embeddability of a JavaScript interpreter, specifically:</p>
	<ol>
	<li><b>Object Translation:</b> If objects/values are passed to/from the interpreter to/from the native language - is that translation handled automatically?</li>
	<li><b>Simplicity:</b> How hard is it to get up-and-running? (Is extra compilation required or is it written using native language code?)</li>
	<li><b>Bleed-through:</b> Can JavaScript communicate to the base language or is it a one-way-street?</li>
	</ol>
	<p>The first point is the easiest one to find compatibility with - virtually all embeddable JavaScript interpreters do some form of object translation. Some do it better (like JE and Rhino) but it generally shouldn't be a problem for simple scripts.</p>
	<h3>PHP</h3>
	<p><b>&raquo; <a href="http://phpjs.berlios.de/">PHPJS</a></b></p>
	<p>A flexible, pure-PHP, JavaScript interpreter that even accepts compiling to an intermediary bytecode. There is no bleed-through but good object translation.</p>
	<div class="syntax_hilite">
<div id="php-15">
	<div><span style="color: #b1b100;">include</span> <span style="color: #ff0000;">"js.php"</span>;</p>
	<p><span style="color:#008000;"># Introduce a new JavaScript function, named print,</span><br />
<span style="color:#008000;"># which calls a PHP function</span><br />
<span style="color: #000000; font-weight: bold;">function</span> show<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #0000ff;">$msg</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"$msg<span style="color: #000099; font-weight: bold;">\n</span>"</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span></p>
	<p><span style="color: #0000ff;">$jsi_vars</span><span style="color:#008800; font-weight:bold;">&#91;</span><span style="color: #ff0000;">"print"</span><span style="color:#008800; font-weight:bold;">&#93;</span> = <span style="color: #ff0000;">"show"</span>;</p>
	<p><span style="color:#008000;"># Add in a new pure-JavaScript function which calls</span><br />
<span style="color:#008000;"># our previously-introduced print function</span><br />
jsc::compile<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"function alert(msg){ print('Alert:' + msg); }"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p><span style="color:#008000;"># Prints out 'Alert: text'</span><br />
js_exec<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"alert('text');"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<p><b>&raquo; <a href="http://j4p5.sourceforge.net/">J2P5: Pure-PHP ECMAScript Engine</a></b></p>
	<p>Probably the simplest of the available interpreters - there doesn't appear to be a clear way of communicating from JavaScript-to-PHP (or vice versa). Although, it is implemented in pure-PHP which allows for some nice cross-platform compatibility.</p>
	<div class="syntax_hilite">
<div id="php-16">
	<div><span style="color: #b1b100;">include</span> <span style="color: #ff0000;">"js/js.php"</span>;</p>
	<p><span style="color: #0000ff;">$script</span> = &lt;&lt;&lt;EOD<br />
&nbsp; <a href="http://www.php.net/print"><span style="color: #000066;">print</span></a><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"Hello from JavaScript"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
EOD;</p>
	<p>js::run<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #0000ff;">$script</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</div>
	</div>
</div>
	<h3>Perl</h3>
	<p><b>&raquo; <a href="http://search.cpan.org/~tbusch/JavaScript-SpiderMonkey-0.19/">JavaScript::SpiderMonkey</a></b></p>
	<p>An embedding of Mozilla's <a href="http://www.mozilla.org/js/spidermonkey/">Spidermonkey</a> JavaScript engine into Perl. Since it uses Spidermonkey it'll require that extra source code and compilation. Object translation is good but there's no bleed-through (JavaScript calling native Perl functionality that isn't explicitly defined).</p>
	<div class="syntax_hilite">
<div id="perl-13">
	<div><span style="color: #000000; font-weight: bold;">use</span> JavaScript::SpiderMonkey;</p>
	<p><span style="color: #808080; font-style: italic;"># Instantiate the interpreter</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$j</span> = JavaScript::SpiderMonkey-&gt;<span style="color: #006600;">new</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Introduce a new JavaScript function, named print,</span><br />
<span style="color: #808080; font-style: italic;"># which calls a Perl function</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">function_set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"print"</span>, <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">@_</span>, <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Add in a new pure-JavaScript function which calls</span><br />
<span style="color: #808080; font-style: italic;"># our previously-introduced print function</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">eval</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"function alert(msg){ print('Alert:' + msg); }"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Prints out 'Alert: text'</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">eval</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"alert('text');"</span><span style="color: #66cc66;">&#41;</span>;</div>
	</div>
</div>
	<p><b>&raquo; <a href="http://search.cpan.org/~sprout/JE-0.021/">JE: Pure-Perl ECMAScript Engine</a></b></p>
	<p>A pure-Perl JavaScript engine - shows incredible promise (probably my favorite new engine in addition to Rhino). Has tremendous potential (including the ability to serialize the runtime environment!).</p>
	<div class="syntax_hilite">
<div id="perl-14">
	<div><span style="color: #000000; font-weight: bold;">use</span> JE;</p>
	<p><span style="color: #808080; font-style: italic;"># Instantiate the interpreter</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$j</span> = <span style="color: #000000; font-weight: bold;">new</span> JE;</p>
	<p><span style="color: #808080; font-style: italic;"># Introduce a new JavaScript function, named print,</span><br />
<span style="color: #808080; font-style: italic;"># which calls a Perl function</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">new_function</span><span style="color: #66cc66;">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> =&gt; <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">@_</span>, <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Add in a new pure-JavaScript function which calls</span><br />
<span style="color: #808080; font-style: italic;"># our previously-introduced print function</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">eval</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"function alert(msg){ print('Alert:' + msg); }"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Prints out 'Alert: text'</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">method</span><span style="color: #66cc66;">&#40;</span>alert =&gt; <span style="color: #ff0000;">"text"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># So does this</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">eval</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"alert('text');"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Introduce the ability to do remote requests</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Net::FTP;</p>
	<p><span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">bind_class</span><span style="color: #66cc66;">&#40;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/package.html"><span style="color: #000066;">package</span></a> =&gt; <span style="color: #ff0000;">"Net::FTP"</span>, name =&gt; <span style="color: #ff0000;">"FTP"</span> <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Execute native Perl functionality (FTP module)</span><br />
<span style="color: #808080; font-style: italic;"># directly from JavaScript</span><br />
<span style="color: #0000ff;">$j</span>-&gt;<span style="color: #006600;">eval</span><span style="color: #66cc66;">&#40;</span>&lt;&lt;<span style="color: #ff0000;">'--end--'</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; var <a href="http://www.perldoc.com/perl5.6/pod/func/connect.html"><span style="color: #000066;">connect</span></a> = <span style="color: #000000; font-weight: bold;">new</span> FTP<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"ftp.mozilla.org"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/connect.html"><span style="color: #000066;">connect</span></a>.get<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"index.html"</span><span style="color: #66cc66;">&#41;</span>;<br />
--end--</div>
	</div>
</div>
	<p>Note the extreme bleed-through that you can achieve with JE (in addition to excellent object translation).</p>
	<h3>Java</h3>
	<p><b>&raquo; <a href="http://www.mozilla.org/rhino/">Rhino</a></b></p>
	<p>Probably one of the most famous embeddable JavaScript implementations. Implemented in pure Java has excellent object translation and perfect bleed-through. The bleeding can even be controlled explicitly at runtime (to create a more confined environment).</p>
	<p>In the following code (using in some of the jQuery build system) two functions are defined which utilize a number of native Java packages - all without ever writing a single line of Java code.</p>
	<div class="syntax_hilite">
<div id="js-12">
	<div>importPackage<span style="color:#008800; font-weight:bold;">&#40;</span>java.<span style="color: #006600;">io</span><span style="color:#008800; font-weight:bold;">&#41;</span>;</p>
	<p><span style="color: #003366; font-weight: bold;">function</span> writeFile<span style="color:#008800; font-weight:bold;">&#40;</span> file, stream <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> buffer = <span style="color: #003366; font-weight: bold;">new</span> PrintWriter<span style="color:#008800; font-weight:bold;">&#40;</span> <span style="color: #003366; font-weight: bold;">new</span> FileWriter<span style="color:#008800; font-weight:bold;">&#40;</span> file <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; buffer.<span style="color: #006600;">print</span><span style="color:#008800; font-weight:bold;">&#40;</span> stream <span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; buffer.<span style="color: #006600;">close</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span></p>
	<p><span style="color: #003366; font-weight: bold;">function</span> read<span style="color:#008800; font-weight:bold;">&#40;</span> file <span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> f = <span style="color: #003366; font-weight: bold;">new</span> File<span style="color:#008800; font-weight:bold;">&#40;</span>file<span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> reader = <span style="color: #003366; font-weight: bold;">new</span> BufferedReader<span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> FileReader<span style="color:#008800; font-weight:bold;">&#40;</span>f<span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> line = <span style="color: #003366; font-weight: bold;">null</span>;<br />
&nbsp; <span style="color: #003366; font-weight: bold;">var</span> buffer = <span style="color: #003366; font-weight: bold;">new</span> java.<span style="color: #006600;">lang</span>.<span style="color: #006600;">StringBuffer</span><span style="color:#008800; font-weight:bold;">&#40;</span>f.<span style="color: #006600;">length</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; <span style="color: #000066; font-weight: bold;">while</span><span style="color:#008800; font-weight:bold;">&#40;</span> <span style="color:#008800; font-weight:bold;">&#40;</span>line = reader.<span style="color: #006600;">readLine</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span><span style="color:#008800; font-weight:bold;">&#41;</span> != <span style="color: #003366; font-weight: bold;">null</span><span style="color:#008800; font-weight:bold;">&#41;</span> <span style="color:#008800; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; buffer.<span style="color: #006600;">append</span><span style="color:#008800; font-weight:bold;">&#40;</span>line<span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; buffer.<span style="color: #006600;">append</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color: #3366CC;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
&nbsp; <span style="color:#008800; font-weight:bold;">&#125;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> buffer.<span style="color: #006600;">toString</span><span style="color:#008800; font-weight:bold;">&#40;</span><span style="color:#008800; font-weight:bold;">&#41;</span>;<br />
<span style="color:#008800; font-weight:bold;">&#125;</span></div>
	</div>
</div>
	<h3>Python</h3>
	<p><b>&raquo; <a href="http://code.google.com/p/python-spidermonkey/">Python-Spidermonkey</a></b></p>
	<p>Previously this was one of the most depressing embedding efforts (and, really, the only one available for Python) but it has since had some new life blown into it - which is much appreciated. It supports decent object translation and bleed-through (including the ability to call native classes, much like in JE).</p>
	<div class="syntax_hilite">
<div id="python-17">
	<div><span style="color: #b1b100;">from</span> spidermonkey <span style="color: #b1b100;">import</span> Runtime</p>
	<p>j = RunTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #202020;">new_context</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></p>
	<p><span style="color: #808080; font-style: italic;"># Introduce a new JavaScript function, named print,</span><br />
<span style="color: #808080; font-style: italic;"># which calls a Python function</span><br />
j.<span style="color: #202020;">bind_callable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"print"</span>, <span style="color: #b1b100;">lambda</span> msg: <span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span>msg<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Add in a new pure-JavaScript function which calls</span><br />
<span style="color: #808080; font-style: italic;"># our previously-introduced print function</span><br />
j.<span style="color: #202020;">eval_script</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"function alert(msg){ print('Alert:' + msg); }"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Prints out 'Alert: text'</span><br />
j.<span style="color: #202020;">eval_script</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"alert('text');"</span><span style="color: #66cc66;">&#41;</span>;</div>
	</div>
</div>
	<h3>Ruby</h3>
	<p>While there was a previous effort to embed Spidermonkey in Ruby it is largely defunct now, superseded by the new (strangely named) Johnson project.</p>
	<p><b>&raquo; <a href="http://github.com/jbarnette/johnson/tree/master">Johnson</a></b></p>
	<p>This is a, relatively, new project that's working to completely overhaul how communication is currently done in-between Ruby and JavaScript (using Spidermonkey to power the engine). There is complete bleed-through: Ruby can dig in and manipulate JavaScript objects at run-time and JavaScript can call back and access native Ruby functionality. Additionally they're examining the ability to provide native browser environments using the <a href="http://ejohn.org/blog/bringing-the-browser-to-the-server/">env.js</a> script that I created last year. While the cross-platform ease-of-use isn't there yet the project absolutely has a ton of potential.</p>
	<div class="syntax_hilite">
<div id="python-18">
	<div>require <span style="color: #ff0000;">"johnson"</span></p>
	<p>j = Johnson::Runtime.<span style="color: #202020;">new</span></p>
	<p><span style="color: #808080; font-style: italic;"># Introduce a new JavaScript function, named print,</span><br />
<span style="color: #808080; font-style: italic;"># which calls a Ruby function</span><br />
j.<span style="color: #202020;">print</span> = <span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#123;</span>|msg| puts msg<span style="color: #66cc66;">&#125;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Add in a new pure-JavaScript function which calls</span><br />
<span style="color: #808080; font-style: italic;"># our previously-introduced print function</span><br />
j.<span style="color: #202020;">evaluate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"function alert(msg){ print('Alert:' + msg); }"</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #808080; font-style: italic;"># Prints out 'Alert: text'</span><br />
j.<span style="color: #202020;">evaluate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"alert('text');"</span><span style="color: #66cc66;">&#41;</span>;</div>
	</div>
</div>
	<p><b>Update:</b> Another example of Johnson in action from <a href="http://geeksomnia.com/">John Barnette</a>:</p>
	<div class="syntax_hilite">
<div id="python-19">
	<div>require <span style="color: #ff0000;">"johnson"</span></p>
	<p><span style="color: #b1b100;">class</span> Monkey<br />
&nbsp; <span style="color: #b1b100;">def</span> eat<br />
&nbsp; &nbsp; puts <span style="color: #ff0000;">"Nom, nom, nom, bananas!"</span><br />
&nbsp; end<br />
end</p>
	<p>j = Johnson::Runtime.<span style="color: #202020;">new</span></p>
	<p><span style="color: #808080; font-style: italic;"># toss a monkey into the runtime</span><br />
m = Monkey.<span style="color: #202020;">new</span><br />
j<span style="color: #66cc66;">&#91;</span>:m<span style="color: #66cc66;">&#93;</span> = m</p>
	<p><span style="color: #808080; font-style: italic;"># add a JSland function to our monkey...</span><br />
j.<span style="color: #202020;">evaluate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"m.chow = function() { this.eat() }"</span><span style="color: #66cc66;">&#41;</span></p>
	<p><span style="color: #808080; font-style: italic;"># ...and now it's available as an instance method on our native Ruby object!</span><br />
m.<span style="color: #202020;">chow</span></div>
	</div>
</div>
	<p>There's a ton of potential in all of these projects - providing interesting features for blurring the lines in-between JavaScript and different host languages. For your next project it should be pretty easy to find a solution to embedding JavaScript as your quick-and-dirty scripting language of choice.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5608" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/312225156" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/spicing-up-embedded-javascript/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fspicing-up-embedded-javascript%2F</feedburner:awareness></item>
		<item>
		<title>Algorithmic Ink in JavaScript</title>
		<link>http://ejohn.org/blog/algorithmic-ink-in-javascript/</link>
		<comments>http://ejohn.org/blog/algorithmic-ink-in-javascript/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 13:01:11 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>visualization</category>
                <category>javascript</category>
		<guid>http://ejohn.org/blog/algorithmic-ink-in-javascript/</guid>
		<description><![CDATA[The always-excellent Aza Raskin had a little bit of fun recently - inspired by my recent Processing.js work - to port the popular Context Free Art language to JavaScript, using Canvas.

Renamed Algorithm Ink the result is a complete way to programmatically generate elegant pieces of artwork. Aza took the result a step further and built [...]]]></description>
			<content:encoded><![CDATA[	<p>The always-excellent <a href="http://azarask.in/blog/">Aza Raskin</a> had a little bit of fun recently - inspired by my recent <a href="http://ejohn.org/blog/processingjs/">Processing.js</a> work - to port the popular <a href="http://www.contextfreeart.org/">Context Free Art</a> language to JavaScript, using Canvas.</p>
	<p>Renamed <a href="http://azarask.in/projects/algorithm-ink/">Algorithm Ink</a> the result is a complete way to programmatically generate elegant pieces of artwork. Aza took the result a step further and built an in-browser IDE, gallery, and real-time result viewing. It appears to work best in Firefox 3, from my initial testing.</p>
	<p>The result of <a href="http://azarask.in/projects/algorithm-ink/#0656fbe7">one piece</a> might look like this:</p>
	<p><center><img src="http://ejohn.org/files/algorithm-ink.sm.png"/></center></p>
	<p>But that's the beauty since you'll likely never get the same piece of art twice. All works are seeded with a bit of randomness in order to create unique works. For example here is the <a href="http://www.contextfreeart.org/">CFA</a> code that generated the above image:</p>
	<pre>startshape scale
	
rule scale{
	SPIKES{ s .03 }
}
	
rule SPIKES {
	SPIKE {}
	SPIKE { r 90 }
	SPIKE { r 180 }
	SPIKE { r 270 }
}
	
rule SPIKE {
	LSPIKE {}
}
rule SPIKE {
	LSPIKE { flip 90 }
}
	
rule LSPIKE {
	SQUARE {}
	LSPIKE { y 0.98 s 0.99 r 1}
}
rule LSPIKE 0.005 {
	SPIKE { r 90 }
	SPIKE { r -90 }
	LSPIKE { y 0.98 s 0.99  r 1}
}
	
rule MOUSECLICK{
  SPIKES{ s .025 }
}</pre>
	<p>The code is quite simple - just a set of rules that are initiated and seeded based upon a few parameters. More information can be found in the <a href="http://www.contextfreeart.org/mediawiki/index.php/CFDG_HOWTO">Context Free Art documentation</a>.</p>
	<p>Of course the entire Context Free port is open source: <a href="http://code.google.com/p/contextfree/source/browse/trunk/contextfree.js">contextfree.js</a>. Looking through the source you'll note that the result is much more math-heavy than Processing performing frequent <a href="http://code.google.com/p/contextfree/source/browse/trunk/contextfree.js#636">matrix-based transformations</a> to the display. The result, however, is that pieces written in CFA (as shown above) involve much less, obvious, mathematical calls and is a much-purer result.</p>
	<p>I think this particular port shows a ton of promise: It shows that it's possible to create elegant works using JavaScript while doing it in a completely standards-based way. I'm excited to see people start to play around with this - I think it shows a lot of promise.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5607" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/309797865" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/algorithmic-ink-in-javascript/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Falgorithmic-ink-in-javascript%2F</feedburner:awareness></item>
		<item>
		<title>Trivial JavaScript</title>
		<link>http://ejohn.org/blog/trivial-javascript/</link>
		<comments>http://ejohn.org/blog/trivial-javascript/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 08:27:15 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>javascript</category>
		<guid>http://ejohn.org/blog/trivial-javascript/</guid>
		<description><![CDATA[I've been chatting with the Free Software Foundation and they've posed a tricky question: What is trivial JavaScript? - or - What is not trivial JavaScript?

It seems like an especially hard question to answer - especially without using subjective terms.

For example I would say that the following are all trivial:

Use of inline JavaScript/DOM 0-style code [...]]]></description>
			<content:encoded><![CDATA[	<p>I've been chatting with the <a href="http://www.fsf.org/">Free Software Foundation</a> and they've posed a tricky question: <b>What is trivial JavaScript?</b> - or - <b>What is not trivial JavaScript?</b></p>
	<p>It seems like an especially hard question to answer - especially without using subjective terms.</p>
	<p>For example I would say that the following are all trivial:</p>
	<ul>
	<li>Use of inline JavaScript/DOM 0-style code (ex. onclick="...").</li>
	<li>Use of unobtrusive scripting to layer on basic page behaviors (ex. Twitter).</li>
	</ul>
	<p>Whereas the following are sufficiently complex as to be deemed not trivial:</p>
	<ul>
	<li>Applications that do Ajax requests to a server-side component (ex. GMail).</li>
	<li>Applications where the majority of the initial download is executable code (ex. <a href="http://280slides.com/">280 Slides</a>).</li>
	<li>Applications that are unable to function without the use of JavaScript (ex. Google Maps).</li>
	</ul>
	<p>But this brings up the question: What about poorly-designed pages that have a small amount of JavaScript but are unable to function without the use of JavaScript? I'd still deem it trivial.</p>
	<p>And what about sites that are somewhere in-between? For example Netflix has a significant amount of unobtrusive JavaScript on their site but I would hardly consider it to be trivial (pop-ups, Ajax-loading, all sorts of unobtrusive interaction).</p>
	<p>Is there a tangible line that is crossed on the road to complex JavaScript development? Is it an externality like storing script in a separate file (ex. &lt;script src='...'>&lt;/script>)? or is it inside the script itself like in using Function prototypes or closures? It feels like the measure should be put upon an external source (as to not make restrictions upon what someone could, or couldn't, write using the language) but what would the proper external measurement be?</p>
	<p>Thoughts?
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5606" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/308837525" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/trivial-javascript/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Ftrivial-javascript%2F</feedburner:awareness></item>
		<item>
		<title>Writing ECMAScript 4, Today</title>
		<link>http://ejohn.org/blog/writing-ecmascript-4-today/</link>
		<comments>http://ejohn.org/blog/writing-ecmascript-4-today/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 07:50:19 +0000</pubDate>
		<dc:creator>John Resig</dc:creator>
		                <category>javascript</category>
                <category>ecmascript</category>
                <category>python</category>
		<guid>http://ejohn.org/blog/writing-ecmascript-4-today/</guid>
		<description><![CDATA[A very cool new utility has just been released by Olav Junker Kjær called Mascara which is an ECMAScript 4 to JavaScript translator (written in Python).

Using this utility you can begin writing ECMAScript 4 code today, receiving its full benefits (such as IDE integration and compile-time type-checking) while still being able to run the resulting [...]]]></description>
			<content:encoded><![CDATA[	<p>A very cool new utility has just been released by Olav Junker Kjær called <a href="http://ecmascript4.com/">Mascara</a> which is an ECMAScript 4 to JavaScript translator (written in Python).</p>
	<p>Using this utility you can begin writing ECMAScript 4 code today, receiving its full benefits (such as IDE integration and compile-time type-checking) while still being able to run the resulting code in all modern browsers.</p>
	<p>A simple demonstration is up on the <a href="http://ecmascript4.com/">Mascara web site</a> which provides a view into the translated source code, along with run-time (and inline) error messages.</p>
	<p>A full break-down of the features currently supported are:</p>
	<ul>
	<li>Type verification</li>
	<li>Classes and inheritance, constructors, super initializers</li>
	<li>Static members</li>
	<li>Type inference from initialization</li>
	<li>Parameterized types, Map and Vector</li>
	<li>Union types</li>
	<li>Structural types</li>
	<li>Getters/setters</li>
	<li>Namespaces</li>
	<li>Nullable types</li>
	</ul>
	<p>Definitely be aware, however, that while the above feature list is more than enough to get started there are still a <a href="http://blog.ecmascript4.com/2008/05/this-is-test.html">a few items left to be implemented</a>.</p>
	<p>The most important question, when looking at the above code, should be: How do I begin using this today? Olav went ahead and made it easy to do IDE integration - even setting up instructions on how to integrate with <a href="http://blog.ecmascript4.com/2008/06/release-013.html">Eclipse on Windows</a> (he currently shows how to integrate using the JScript command-line interface, but it can easily be expanded). I'm quite excited by this prospect - having the ability to do compile-time type-checking and be able to succinctly write classes with inheritance will be a major boon to development.</p>
	<p>Additionally, he provides information on how to do <a href="http://blog.ecmascript4.com/2008/06/version-015-released.html">automatic CGI translation</a> (naturally, you would want to do this only in a development environment).</p>
	<p>He's continuing to provide frequent updates on the <a href="http://blog.ecmascript4.com/">Mascara blog</a> - be sure to follow along if you're interested in starting to use ECMAScript 4 sooner, rather than later.
</p>
		<img src="http://ejohn.org/apps/rss/?from=rss&id=5605" style="width:0px;height:0px;"/><img src="http://feeds.feedburner.com/~r/JohnResig/~4/308818566" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRSS>http://ejohn.org/blog/writing-ecmascript-4-today/feed/</wfw:commentRSS>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=JohnResig&amp;itemurl=http%3A%2F%2Fejohn.org%2Fblog%2Fwriting-ecmascript-4-today%2F</feedburner:awareness></item>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetFeedData?uri=JohnResig</feedburner:awareness></channel>
</rss>
