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

<channel>
	<title>BorkWeb &#187; js</title>
	<atom:link href="http://borkweb.com/story/tag/js/feed" rel="self" type="application/rss+xml" />
	<link>http://borkweb.com</link>
	<description>Some People Are Squirrel Handed.</description>
	<lastBuildDate>Tue, 17 Jan 2012 22:00:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Web Programming Guest Lecture: JavaScript</title>
		<link>http://borkweb.com/story/web-programming-guest-lecture-javascript</link>
		<comments>http://borkweb.com/story/web-programming-guest-lecture-javascript#comments</comments>
		<pubDate>Mon, 07 Dec 2009 21:37:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[dougless crockford]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[plymouth state]]></category>
		<category><![CDATA[psu]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/web-programming-guest-lecture-javascript</guid>
		<description><![CDATA[I have once again given a JavaScript guest lecture to Zach&#8216;s Web Programming class. This year I have taken the liberty of swiping some of Douglas Crockford&#8217;s &#8220;JavaScript: The Good Parts&#8221; presentation for the leading slides. Here&#8217;s the presentation: Javascript 2009 View more presentations from borkweb.]]></description>
			<content:encoded><![CDATA[<p>I have once again given a JavaScript guest lecture to <a href="http://nosheep.net">Zach</a>&#8216;s Web Programming class.  This year I have taken the liberty of swiping some of Douglas Crockford&#8217;s &#8220;<a href="http://googlecode.blogspot.com/2009/03/doug-crockford-javascript-good-parts.html">JavaScript: The Good Parts</a>&#8221; presentation for the leading slides.</p>
<p>Here&#8217;s the presentation:</p>
<div style="width:425px;text-align:left" id="__ss_2668223"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/borkweb/javascript-2009" title="Javascript 2009">Javascript 2009</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=javascript2009-091207131734-phpapp01&#038;stripped_title=javascript-2009" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=javascript2009-091207131734-phpapp01&#038;stripped_title=javascript-2009" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/borkweb">borkweb</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/web-programming-guest-lecture-javascript/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Guest Lecture: JavaScript, Ajax &amp; DOM Manipulation</title>
		<link>http://borkweb.com/story/guest-lecture-javascript-ajax-dom-manipulation</link>
		<comments>http://borkweb.com/story/guest-lecture-javascript-ajax-dom-manipulation#comments</comments>
		<pubDate>Wed, 03 Dec 2008 19:16:52 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ecmascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[plymouth]]></category>
		<category><![CDATA[plymouth state university]]></category>
		<category><![CDATA[psu]]></category>

		<guid isPermaLink="false">http://borkweb.com/?p=656</guid>
		<description><![CDATA[Zach has asked me to give a JavaScript guest lecture in his Web Programming class. We&#8217;ll cover: JS basics, node manipulation, DOM traversal, AJAX, JavaScript libraries, and myPlymouth implementations of those topics. Here are the slides (get the .ppt here): Javascript: Ajax &#38; DOM Manipulation v1.2 View SlideShare presentation or Upload your own. (tags: javascript [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nosheep.net">Zach</a> has asked me to give a JavaScript guest lecture in his Web Programming class.  We&#8217;ll cover: JS basics, node manipulation, DOM traversal, AJAX, JavaScript libraries, and myPlymouth implementations of those topics.  Here are the slides (get the .ppt <a href="http://borkweb.com/examples/js_workshop/javascript.ppt">here</a>):</p>
<div class="center">
<div style="width:425px;text-align:left" id="__ss_814300"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/borkweb/javascript-ajax-and-the-dom-v12-presentation?type=powerpoint" title="Javascript: Ajax &amp; DOM Manipulation v1.2">Javascript: Ajax &amp; DOM Manipulation v1.2</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=javascript-1228331371388010-8&#038;stripped_title=javascript-ajax-and-the-dom-v12-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=javascript-1228331371388010-8&#038;stripped_title=javascript-ajax-and-the-dom-v12-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View SlideShare <a style="text-decoration:underline;" href="http://www.slideshare.net/borkweb/javascript-ajax-and-the-dom-v12-presentation?type=powerpoint" title="View Javascript: Ajax &amp; DOM Manipulation v1.2 on SlideShare">presentation</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">Upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/javascript">javascript</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/jquery">jquery</a>)</div>
</div>
</div>
<p>A few resources that are mentioned:</p>
<ul>
<li><a href="http://borkweb.com/story/must-have-extensions-for-firefox">Firefox Extensions</a> (including <a href="http://getfirebug.com">Firebug</a>)</li>
<li><a href="http://jquery.com">jQuery</a></li>
<li><a href="http://borkweb.com/examples/js_workshop/">Slide Examples</a></li>
<li><a href="http://borkweb.com/playground/sprite/sprite.html">MegaMan Sprite Animation</a></li>
</ul>
<p><em>Note: this is an updated talk on the <a href="http://borkweb.com/story/plymouth-state-javascript-workshop">workshop</a> I led two years ago</em></p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/guest-lecture-javascript-ajax-dom-manipulation/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Book Review: Learning jQuery</title>
		<link>http://borkweb.com/story/book-review-learning-jquery</link>
		<comments>http://borkweb.com/story/book-review-learning-jquery#comments</comments>
		<pubDate>Mon, 06 Aug 2007 22:21:08 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jonathan chaffer]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[karl swedberg]]></category>
		<category><![CDATA[learning jquery]]></category>
		<category><![CDATA[packt publishing]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/book-review-learning-jquery</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/exec/obidos/ASIN/1847192505/masterwishcom-20"><img src="http://ec1.images-amazon.com/images/I/51A2eSmL4QL._AA240_.jpg" class="post_image" float:left;"/></a> I&#8217;m  a <a href="http://borkweb.com/story/the-ajax-experience-jquery-toolkit">huge fan</a> and avid user of <a href="http://jquery.com">jQuery</a> and have been extremely impressed by the <a href="http://docs.google.com">documentation</a> provided on the jQuery website.  The one thing that documentation lacks, however, is really contextual examples that drive home some bare essentials of JavaScripting with the jQuery library.  <strong>Learning jQuery</strong> &#8211; a book by Jonathan Chaffer and Karl Swedberg &#8211; is an excellent introductory book for those that are thinking about using (or struggling with) jQuery.  </p>
<p>jQuery, while a fairly high level JavaScript library is a beautiful thing but can be very daunting to a developer that is new to JavaScripting or is coming from a dissimilar library, being thrust full bore into a &#8216;new&#8217; way of doing old tricks. (Which jQuery is great at by the way&#8230;it makes the new ways super sexy, sleek, and easy).  The authors do a great job of explaining <em>what</em> jQuery is and <em>why</em> it is such a powerful tool.</p>
<p>Throughout the book are examples on traversing and manipulating the <a href="http://borkweb.com/story/node-manipulation-in-the-dom">DOM</a>, event handling, leveraging jQuery&#8217;s JS effect capabilities, <a href="http://borkweb.com/story/ajax-more-than-a-buzz-word">AJAX</a>, etc; many of which are built off of previously detailed examples, allowing the reader to easily grasp what is going on and <em>why</em> a chunk of code was used.  </p>
<p>While I feel this book is primarily an <strong>excellent</strong> introductory source for diving into the world of JavaScript development with jQuery, the fairly seasoned jQuery user (like myself) may find a trick or two that they hadn&#8217;t quite thought of&#8230;  As I read through, I found a few choice bits that allowed me to make <em>my own</em> code more efficient!  </p>
<p>My only real complaint with the book is the index at the back.  There are a number of jQuery functions that are discussed within the chapters yet weren&#8217;t referenced in the index.  A small nitpick, I know, but I&#8217;m a sucker for a good index :)</p>
<p>So.  Overall, I think the book is a good thing to keep on the bookshelf, whether a you are a jQuery n00b or not.  There&#8217;s always a co-worker/friend/programming buddy that will want to learn jQuery and what better way to get them rolling on there own than a link to the jQuery docs and a sweet book?</p>
<p>You can get the book <a href="http://www.amazon.com/exec/obidos/ASIN/1847192505/masterwishcom-20">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/book-review-learning-jquery/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery 1.1.3: Speed Improvements and Bug Fixes</title>
		<link>http://borkweb.com/story/jquery-113-speed-improvements-and-bug-fixes</link>
		<comments>http://borkweb.com/story/jquery-113-speed-improvements-and-bug-fixes#comments</comments>
		<pubDate>Mon, 02 Jul 2007 11:44:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/jquery-113-speed-improvements-and-bug-fixes</guid>
		<description><![CDATA[After a long wait, jQuery 1.1.3 has been released! (Download it at the jQuery site) When I first adopted jQuery a year ago, the library boasted both faster speeds and smaller size than any other JavaScript Ajax/DOM tool. With the release of jQuery&#8217;s version 1.1.2, a number of jQuery&#8217;s operations became very slow and inefficiencient, [...]]]></description>
			<content:encoded><![CDATA[<p>After a long wait, jQuery 1.1.3 has been released! (Download it at the <a href="http://jquery.com">jQuery site</a>)  When I first adopted jQuery a year ago, the library boasted both faster speeds and smaller size than any other JavaScript Ajax/DOM tool.  With the release of jQuery&#8217;s version 1.1.2, a number of jQuery&#8217;s operations became very slow and inefficiencient, as evidenced by MooTool&#8217;s <a href="http://mootools.net/slickspeed/">SlickSpeed CSS Selector Test</a> (found via <a href="http://ajaxian.com/archives/slickspeed-css-selector-testsuite">Ajaxian</a>) which crept up a few weeks ago.</p>
<p>This new release boasts an 800% speed improvement with a number of its selectors along with various enhancements across the board!  The selector speed boost makes me one happy camper.  Check out the enhancements as it compares to 1.1.2:</p>
<table>
<thead>
<tr>
<th>Browser</th>
<th>jQuery 1.1.2</th>
<th>jQuery 1.1.3</th>
<th>% Improvement</th>
</tr>
</thead>
<tbody>
<tr>
<th>IE 6</th>
<td>4890ms</td>
<td>661ms</td>
<th>740%</th>
</tr>
<tr>
<th>Firefox 2</th>
<td>5629ms</td>
<td>567ms</td>
<th>993%</th>
</tr>
<tr>
<th>Safari 2</th>
<td>3575ms</td>
<td>475ms</td>
<th>753%</th>
</tr>
<tr>
<th>Opera 9.1</th>
<td>3196ms</td>
<td>326ms</td>
<th>980%</th>
</tr>
<tr>
<td colspan="3" style="text-align: right;">Average improvement:</td>
<th>867%</th>
</tr>
</tbody>
</table>
<p>And here&#8217;s how it now stacks up against the SlickSpeed test:</p>
<table>
<thead>
<tr>
<th>Browser</th>
<th>Prototype</th>
<th>jQuery</th>
<th>Mootools</th>
<th>Ext</th>
<th>Dojo</th>
</tr>
</thead>
<tbody>
<tr>
<th>IE 6</th>
<td>1476ms</td>
<th>661ms</th>
<td>1238ms</td>
<td>672ms</td>
<td>738ms</td>
</tr>
<tr>
<th>Firefox 2</th>
<td>219ms</td>
<td>567ms</td>
<td>220ms</td>
<td>951ms</td>
<td>440ms</td>
</tr>
<tr>
<th>Safari 2</th>
<td>1568ms</td>
<td>475ms</td>
<td>909ms</td>
<td>417ms</td>
<td>527ms</td>
</tr>
<tr>
<th>Opera 9.1</th>
<td>220ms</td>
<td>326ms</td>
<td>217ms</td>
<td>296ms</td>
<td>220ms</td>
</tr>
</tbody>
</table>
<p>In addition to the speed enhancements, there were several other notable things:</p>
<ul>
<li><strong>Unicode Selectors</strong>: Yup&#8230;now you can use fancy non-english characters.</li>
<li><strong>Escape Selectors</strong>:  This is awesome.  Now, if you use weird characters (i.e. punctuation) in a class/id name, you can now escape those characters within the selector syntax.  E.g. <em>$(&#8220;div#foo\.bar&#8221;)</em></li>
<li><strong>Inequality Selector</strong>: You can now select elements where their attributes do not match a specific string of characters.  E.g. <em>$(&#8220;div[@id!=test]&#8220;)</em></li>
<li><strong>:nth-child() improvements</strong>: jQuery has supported selectors like :nth-child(1) and :nth-child(odd) since the beginning of jQuery, now they’ve added advanced :nth-child selectors, such as:
<ul>
<li>$(&#8220;div:nth-child(2n)&#8221;)</li>
<li>$(&#8220;div:nth-child(2n+1)&#8221;)</li>
<li>$(&#8220;div:nth-child(n)&#8221;)</li>
</ul>
</li>
<li><strong>Space-separated attributes</strong>: After being removed in jQuery 1.0, this selector has now been brought back by popular demand. It allows you to locate individual items in a space-separated attribute (such as a class or rel attribute).  E.g. <em>$(&#8220;a[@rel~=test]&#8220;)</em></li>
<li><strong>Animation Improvements</strong>: Animations are now significantly faster and smoother. Additionally, you can run more simultaneous animations without incurring any speed hits.</li>
<li><strong>DOM Event Listeners</strong>: Internally, the jQuery Event system has been overhauled to use the DOM Event system, rather than the classical “onclick” style of binding event handlers. This improvement allows you to be more unobtrusive in your use of the library (not affecting the flow of other libraries around it). Additionally, it helped to resolve some of the outstanding issues that existed with binding event listeners to IFrames.</li>
<li><strong>Event Normalization</strong>: Some great steps have been taken to normalize keyboard and mouse events. You can now access the event.which property to get most details about the specific key or button that was pressed.</li>
<li><strong>Multiple .is()</strong>: The .is() method can now take multiple selectors, separated by a comma. This allows you to test your jQuery set against multiple selectors. E.g. <em>$(&#8220;div&#8221;).is(&#8220;:visible, :first&#8221;)</em></li>
<li><strong>Browser Version</strong>: A commonly requested feature, by plugin authors, was a way to determine what browser version their users were using. We now expose an extra property through which this information can be accessed. E.g. <em>jQuery.browser.version</em></li>
</ul>
<p>Additionally, the jQuery team has addressed 80+ bugs and has roadmapped out the next two releases (v1.1.4 and v1.2).  To check out the full jQuery 1.2 roadmap, <a href="http://docs.jquery.com/JQuery_1.2_Roadmap">go here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/jquery-113-speed-improvements-and-bug-fixes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSMin: Javascript Compression</title>
		<link>http://borkweb.com/story/jsmin-javascript-compression</link>
		<comments>http://borkweb.com/story/jsmin-javascript-compression#comments</comments>
		<pubDate>Mon, 01 Jan 2007 23:49:50 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[douglas crockford]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[jsmin]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/jsmin-javascript-compression</guid>
		<description><![CDATA[While at The Ajax Experience in October, I attended a presentation who spoke of the 3 C&#8217;s (Combine, Compress, Cache) for Ajax development. In the Compress section I was introduced to the beauty of JSMin! What is it? Well, shut up and I&#8217;ll tell you. Quoting Douglas Crockford (the creator of JSMin): JSMin is a [...]]]></description>
			<content:encoded><![CDATA[<p>While at <a href="http://borkweb.com/story/the-ajax-experience">The Ajax Experience</a> in October, I attended <a href="http://borkweb.com/story/the-ajax-experience-leveraging-ajax-for-enterprise-application-development">a presentation</a> who spoke of the 3 C&#8217;s (Combine, Compress, Cache) for Ajax development.  In the Compress section I was introduced to the beauty of <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a>!</p>
<p>What is it? Well, shut up and I&#8217;ll tell you.</p>
<p>Quoting <a href="http://www.crockford.com/">Douglas Crockford</a> (the creator of JSMin):</p>
<blockquote><p>
JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.
</p></blockquote>
<p>As I&#8217;ve been creating more complex Javascript applications, the file size has been increasing (although the size is greatly reduced, thanks to <a href="http://borkweb.com/story/the-ajax-experience-jquery-toolkit">jQuery</a>).  And, as a careful programmer should, I place comments all over my Javascript code so I don&#8217;t draw too many blanks while updating/debugging&#8230;well, those comments tend to bloat the file size, as does the whitespace.  The stripping of those elements alone has dropped the file-size of a number of my scripts by 40-50%!  Thats huge.  What previously was an 8K file goes down to 4K.  Awesome.  </p>
<p>If you&#8217;re curious what JSMin does to your code, here&#8217;s an example that Douglas gives:<br />
<strong>Before</strong></p>
<pre class="brush: jscript; title: ; notranslate">
// is.js

// (c) 2001 Douglas Crockford
// 2001 June 3

// is

// The -is- object is used to identify the browser.  Every browser edition
// identifies itself, but there is no standard way of doing it, and some of
// the identification is deceptive. This is because the authors of web
// browsers are liars. For example, Microsoft's IE browsers claim to be
// Mozilla 4. Netscape 6 claims to be version 5.

var is = {
    ie:      navigator.appName == 'Microsoft Internet Explorer',
    java:    navigator.javaEnabled(),
    ns:      navigator.appName == 'Netscape',
    ua:      navigator.userAgent.toLowerCase(),
    version: parseFloat(navigator.appVersion.substr(21)) ||
             parseFloat(navigator.appVersion),
    win:     navigator.platform == 'Win32'
}
is.mac = is.ua.indexOf('mac') &gt;= 0;
if (is.ua.indexOf('opera') &gt;= 0) {
    is.ie = is.ns = false;
    is.opera = true;
}
if (is.ua.indexOf('gecko') &gt;= 0) {
    is.ie = is.ns = false;
    is.gecko = true;
}
</pre>
<p><strong>After</strong></p>
<pre class="brush: jscript; title: ; notranslate">
var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
is.mac=is.ua.indexOf('mac')&gt;=0;if(is.ua.indexOf('opera')&gt;=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')&gt;=0){is.ie=is.ns=false;is.gecko=true;}
</pre>
<p>As you can see&#8230;the result is not easily read so you&#8217;ll want to keep your original script around in the event that editing is needed.  Super cool.  So how do you get it?  Well&#8230;there&#8217;s a number of languages that JSMin logic has been ported to: <a href="http://www.crockford.com/javascript/jsmin.zip">zip file containing<br />
  an MS-DOS.exe file</a>, or you can get the <a href="http://www.crockford.com/javascript/jsmin.c">C source code</a> and build it yourself. Now in <a href="http://www.crockford.com/javascript/jsmin.cs">C#</a> and <a href="http://inconspicuous.org/projects/jsmin/JSMin.java">Java</a> and <a href="http://fmarcia.info/jsmin/">JavaScript</a> and <a href="http://search.cpan.org/%7Eherrera/JavaScript-Minifier-0.01/lib/JavaScript/Minifier.pm">Perl</a> and <a href="http://www.crockford.com/javascript/jsmin2.php.txt">PHP</a> and <a href="http://www.crockford.com/javascript/jsmin.py.txt">Python</a> and <a href="http://www.crockford.com/javascript/jsmin.rb">Ruby</a>.</p>
<p>If you haven&#8217;t thought about Javascript compression yet, you might want to start.  Try it out&#8230;you&#8217;ll be happy you did.  Oh, and if you are curious: the <a href="http://fmarcia.info/jsmin/">Javascript</a> implementation of JSMin is my favorite as it gives some excellent feedback and comment options on compression.</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/jsmin-javascript-compression/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Remote JavaScripting Example &#8211; Part I</title>
		<link>http://borkweb.com/story/remote-javascripting-example-part-i</link>
		<comments>http://borkweb.com/story/remote-javascripting-example-part-i#comments</comments>
		<pubDate>Fri, 22 Sep 2006 15:47:59 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[matt batchelder]]></category>
		<category><![CDATA[matthew batchelder]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[zach tirrell]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/remote-javascripting-example-part-i</guid>
		<description><![CDATA[[[innerindex]]At Plymouth State we work in a multi-server environment and often wish to display dynamic content from one server in an Ajax-like fashion on another server&#8217;s website. My co-worker, Zach Tirrell, and I have drummed up a solution that works to keep our layout and logic separate, while still serving our end users in a [...]]]></description>
			<content:encoded><![CDATA[<p>[[innerindex]]At <a href="http://www.plymouth.edu">Plymouth State</a> we work in a multi-server environment and often wish to display dynamic content from one server in an Ajax-like fashion on another server&#8217;s website.  My co-worker, <a href="http://nosheep.net">Zach Tirrell</a>, and I have drummed up a solution that works to keep our <a href="http://borkweb.com/story/ajax-templating-and-the-separation-of-layout-and-logic">layout and logic separate</a>, while still serving our end users in a smooth, seamless, non-iFramed manner.</p>
<p>I&#8217;ll walk through the creation of a <em>simple</em> search &#8216;widget&#8217; that relies on dynamic data to populate a drop-down box.</p>
<h2 id="_the-tools_1" >The Tools</h2>
<p>- <a href="http://php.net">PHP</a><br />
- JavaScript<br />
- <a href="http://xtpl.sf.net">XTemplate</a><br />
- <a href="http://borkweb.com/code/remote_widget/includes/RemoteJSOutput.class.phps">RemoteJSOutput</a>: a simple script by <a href="http://borkweb.com">Matthew Batchelder</a> (me) and <a href="http://nosheep.net">Zach Tirrell</a></p>
<h2 id="_step-1-create-your-t_1" >Step 1: create your template</h2>
<p>This widget is fairly simple and thus has a simple template.  The template syntax is simply <a href="http://xtpl.sf.net">XTemplate</a> syntax.  </p>
<p>I&#8217;ll name it <strong>widget.tpl</strong> and store it in a templates directory.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- BEGIN: main --&gt;
&lt;div id=&quot;sweet_borkweb_widget&quot; style=&quot;background:#eee;border:1px solid #ccc;text-align:center;&quot;&gt;
  &lt;div style=&quot;color:#000;&quot;&gt;A Couple JavaScript Posts at BorkWeb&lt;/div&gt;
  &lt;select id=&quot;borkweb_posts&quot;&gt;
    &lt;option value=&quot;&quot;&gt;&lt;/option&gt;
  &lt;!-- BEGIN: post --&gt;
    &lt;option value=&quot;{post.url}&quot;&gt;{post.title}&lt;/option&gt;
  &lt;!-- END: post --&gt;
  &lt;/select&gt;
&lt;/div&gt;
&lt;!-- END: main --&gt;
</pre>
<h2 id="_step-2-simple-templa_1" >Step 2: simple template output</h2>
<p>First we&#8217;ll just spit out the template.  Lets create a PHP file to do this.  We&#8217;ll call it <strong>widget.php</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
include('includes/xtemplate.php');
$xtpl = new XTemplate('templates/widget.tpl');

$xtpl-&gt;parse('main');
$xtpl-&gt;out('main');
?&gt;
</pre>
<p>Check out your widget so far.  Its plain.  Lets change that.</p>
<h2 id="_step-3-add-dynamic-c_1" >Step 3: add dynamic content</h2>
<p>We want the drop down list to hold BorkWeb articles.  We&#8217;ll add that in now.</p>
<p>Note: this is where you would normally pull from a database, an RSS feed, or some other source.  For simplicty, we&#8217;ll be using a simple PHP array.  Whoop-de-doo.  Here it is:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
include('includes/xtemplate.php');
$xtpl = new XTemplate('templates/widget.tpl');

//get list of articles
$articles=array(
  array('title'=&gt;'Ajax, More Than A Buzz Word','url'=&gt;'http://borkweb.com/story/ajax-more-than-a-buzz-word'),
  array('title'=&gt;'Ajax; Templating; and the Separation of Layout and Logic','url'=&gt;'http://borkweb.com/story/ajax-templating-and-the-separation-of-layout-and-logic'),
  array('title'=&gt;'Deleting the Internet','url'=&gt;'http://borkweb.com/story/deleting-the-internet'),
  array('title'=&gt;'Node Manipulation in the DOM','url'=&gt;'http://borkweb.com/story/node-manipulation-in-the-dom'),
  array('title'=&gt;'Prototype Cheat Sheets','url'=&gt;'http://borkweb.com/story/prototype-cheat-sheets'),
  array('title'=&gt;'Script.aculo.us Is My New Best Friend','url'=&gt;'http://borkweb.com/story/scriptaculous-is-my-new-best-friend'),
  array('title'=&gt;'The Case For JSON: What Is It and Why Use It?','url'=&gt;'http://borkweb.com/story/the-case-for-json-what-is-it-and-why-use-it')
);

//loop over articles and place in template
foreach($articles as $article)
{
  $xtpl-&gt;assign('post',$article);
  $xtpl-&gt;parse('main.post');
}//end foreach

$xtpl-&gt;parse('main');
$xtpl-&gt;out('main');
?&gt;
</pre>
<p>Check out your widget now.  It has been populated with some data!  w00t!  Now to make it work, we return to our beloved <strong>widget.tpl</strong> template file.</p>
<h2 id="_step-4-make-the-temp_1" >Step 4: make the template work</h2>
<p>We&#8217;re going to add in some javascript.  Lets make the dropdown list redirect the user to the selected article when the drop-down box changes.</p>
<p>I&#8217;m going to add this on our select box:</p>
<pre class="brush: xml; title: ; notranslate">
 onchange=&quot;if(document.getElementById('borkweb_posts').value!='') document.location=document.getElementById('borkweb_posts').value;&quot;
</pre>
<p>The template should now look like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- BEGIN: main --&gt;
&lt;div id=&quot;sweet_borkweb_widget&quot; style=&quot;background:#eee;border:1px solid #ccc;text-align:center;&quot;&gt;
  &lt;div style=&quot;color:#000;&quot;&gt;A Couple JavaScript Posts at BorkWeb&lt;/div&gt;
  &lt;select id=&quot;borkweb_posts&quot; onchange=&quot;if(document.getElementById('borkweb_posts').value!='') document.location=document.getElementById('borkweb_posts').value;&quot;&gt;
    &lt;option value=&quot;&quot;&gt;&lt;/option&gt;
  &lt;!-- BEGIN: post --&gt;
    &lt;option value=&quot;{post.url}&quot;&gt;{post.title}&lt;/option&gt;
  &lt;!-- END: post --&gt;
  &lt;/select&gt;
&lt;/div&gt;
&lt;!-- END: main --&gt;
</pre>
<h2 id="_step-5-prepare-scrip_1" >Step 5: prepare script for remoting</h2>
<p>Now that our lovely widget is functioning, lets prepare it for inclusion in other locations.  This is simple using <a href="http://borkweb.com/code/remote_widget/includes/RemoteJSOutput.class.php">RemoteJSOutput</a> (a simple script written by <a href="http://nosheep.net">Zach Tirrell</a> and <a href="http://borkweb.com">myself</a>).  </p>
<p>We&#8217;ll include that PHP class and use it as follows:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
include('includes/RemoteJSOutput.class.php');
$remoteOutput=new RemoteJSOutput();

//start output buffering via
$remoteOutput-&gt;start();

include('includes/xtemplate.php');
$xtpl = new XTemplate('templates/widget.tpl');

//get list of articles
$articles=array(
  array('title'=&gt;'Ajax, More Than A Buzz Word','url'=&gt;'http://borkweb.com/story/ajax-more-than-a-buzz-word'),
  array('title'=&gt;'Ajax; Templating; and the Separation of Layout and Logic','url'=&gt;'http://borkweb.com/story/ajax-templating-and-the-separation-of-layout-and-logic'),
  array('title'=&gt;'Deleting the Internet','url'=&gt;'http://borkweb.com/story/deleting-the-internet'),
  array('title'=&gt;'Node Manipulation in the DOM','url'=&gt;'http://borkweb.com/story/node-manipulation-in-the-dom'),
  array('title'=&gt;'Prototype Cheat Sheets','url'=&gt;'http://borkweb.com/story/prototype-cheat-sheets'),
  array('title'=&gt;'Script.aculo.us Is My New Best Friend','url'=&gt;'http://borkweb.com/story/scriptaculous-is-my-new-best-friend'),
  array('title'=&gt;'The Case For JSON: What Is It and Why Use It?','url'=&gt;'http://borkweb.com/story/the-case-for-json-what-is-it-and-why-use-it')
);

//loop over articles and place in template
foreach($articles as $article)
{
  $xtpl-&gt;assign('post',$article);
  $xtpl-&gt;parse('main.post');
}//end foreach

$xtpl-&gt;parse('main');
$xtpl-&gt;out('main');

//spit out script encased in JS
$remoteOutput-&gt;puke();
?&gt;
</pre>
<p>Now check out your widget.  Ugly, huh?  Well, don&#8217;t worry, thats the way its supposed to look for now.</p>
<h2 id="_step-6-place-your-wi_1" >Step 6: place your widget somewhere</h2>
<p>Now that we have that beautiful chunk of code in operation, place it on a webpage somewhere.  </p>
<p>Put this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://url.to/your/widget.php&quot;&gt;&lt;/script&gt;
</pre>
<p>on any page you wish to test your widget!</p>
<h2 id="_optional-step-7-crea_1" >Optional Step 7: create a wrapper</h2>
<p>If, like me, you aren&#8217;t a fan of including RemoteJSOutput.class.php all over hell&#8217;s half acre, you can create a wrapper.  This not only allows you to minimize the code you have to repeatedly place everywhere, but it also keeps your <strong>widget.php</strong> script functional on its own!</p>
<p>Here&#8217;s an example wrapper I&#8217;ll call <strong>get_script.php</strong> which will display <strong>wrapper_widget.php</strong> (step 3&#8242;s PHP file, renamed):</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
include('includes/RemoteJSOutput.class.php');
$remoteOutput=new RemoteJSOutput();

//start output buffering via
$remoteOutput-&gt;start();

//create a list of allowable widgets/scripts/yadda yadda
$allow=array('wrapper_widget');

//does the passed variable exist in the allowable widgets?
if(in_array($_GET['script'],$allow))
{
  //include the wrapper
  include($_GET['script'].'.php');
}//end if

//spit out script encased in JS
$remoteOutput-&gt;puke();
?&gt;
</pre>
<p>So rather than using the script tag that Step 6 suggests, we&#8217;d use:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://url.to/your/get_script.php?script=wrapper_widget&quot;&gt;&lt;/script&gt;
</pre>
<h2 id="_conclusion_1" >Conclusion</h2>
<p>This method is simplistic and is simply touching on the topic of widgetization.  I will be following up with dynamic user interactions in Part II, and finally discuss an open-standard widget library with xml definitions.  Stay tuned :)</p>
<h2 id="_download_1" >Download</h2>
<p>Oh, and <a href="http://borkweb.com/code/remote_widget/remote_widget.zip">here&#8217;s the code</a> used in this tutorial all zipped up.</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/remote-javascripting-example-part-i/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Script.aculo.us v1.6 Released</title>
		<link>http://borkweb.com/story/scriptaculous-v16-soon</link>
		<comments>http://borkweb.com/story/scriptaculous-v16-soon#comments</comments>
		<pubDate>Mon, 27 Mar 2006 21:14:59 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[dom manipulation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[manipulation]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[script.aculo.us]]></category>

		<guid isPermaLink="false">http://borkweb.com/story/scriptaculous-v16-soon</guid>
		<description><![CDATA[Great news over at Mir.aculo.us. It appears as if version 1.6 of my favorite DOM manipulation library, Script.aculo.us has been released! Thankfully the new version of Script.aculo.us uses Prototype v1.5. This is sexy because now I can revert to downloading both Prototype and Script.aculo.us right from the Script.aculo.us site. (Hooray for being lazy) Here&#8217;s an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://script.aculo.us"><img src='http://www.borkweb.com/wp-content/upload/scriptaculous.gif' align="left" class="post_image"/></a>Great news over at <a href="http://mir.aculo.us/articles/2006/03/27/script-aculo-us-1-6-is-coming">Mir.aculo.us</a>.  It appears as if version 1.6 of <a href="http://borkweb.com/story/scriptaculous-is-my-new-best-friend">my favorite</a> DOM manipulation library, <a href="http://script.aculo.us">Script.aculo.us</a> has been released!  Thankfully the new version of Script.aculo.us uses <a href="http://borkweb.com/story/prototype-makes-javascript-painless">Prototype</a> v1.5.</p>
<p>This is sexy because now I can revert to downloading both Prototype <em>and</em> Script.aculo.us right from the Script.aculo.us site.  (Hooray for being lazy)</p>
<p>Here&#8217;s an excerpt from the original post:</p>
<blockquote><p>
script.aculo.us 1.6 marks the switch over to Prototype 1.5 (1.4 will no longer be supported), which has really great new features and has undergone some refactoring to take advantage of the Prototype 1.5 niceties.</p>
<p>Other new stuff includes window-scrolling while dragging, performance optimizations and various bug fixes.</p></blockquote>
<p>They are urging people to test out 1.6.  Get on it!</p>
]]></content:encoded>
			<wfw:commentRss>http://borkweb.com/story/scriptaculous-v16-soon/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

