<?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>Scott Grogan</title>
	<atom:link href="http://www.blog.ninjascript.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.ninjascript.com</link>
	<description>Builds things, mostly with code. </description>
	<lastBuildDate>Mon, 28 Feb 2011 05:35:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Ant FTP task on OS X</title>
		<link>http://www.blog.ninjascript.com/2011/02/ant-ftp-task-on-os-x/</link>
		<comments>http://www.blog.ninjascript.com/2011/02/ant-ftp-task-on-os-x/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 21:09:50 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=29</guid>
		<description><![CDATA[I just spent a good deal of time trying to get the optional FTP task working with the default ant install on OS X 6.4. The most useful information on this topic that I found online was right here: http://mactip.blogspot.com/2009/02/ant-ftp-task-libraries-jakarta-oro.html. If you scroll down to the comments section: &#34;Whoever built the Ant distro from Apple [...]]]></description>
				<content:encoded><![CDATA[<p>I just spent a good deal of time trying to get the optional FTP task working with the default ant install on OS X 6.4. The most useful information on this topic that I found online was right here: <a href="http://mactip.blogspot.com/2009/02/ant-ftp-task-libraries-jakarta-oro.html">http://mactip.blogspot.com/2009/02/ant-ftp-task-libraries-jakarta-oro.html</a>. If you scroll down to the comments section:</p>
<blockquote><p>
&quot;Whoever built the Ant distro from Apple didn&#8217;t have all the optional JAR files to hand, so things like the ssh task wont work even if you add jsch.jar to ~/.ant/lib&quot;<br />
<em class="credit">&mdash; SteveL (on the Ant dev team)</em>
</p></blockquote>
<p>So that pretty much nailed it. Time to upgrade. For this you&#8217;re going to need:</p>
<ul>
<li><a href="http://ant.apache.org/bindownload.cgi">The latest version of ant</a>. <em>(1.8.2 as of this post)</em>
<li><a href="http://commons.apache.org/net/download_net.cgi">The Apache Commons Net jarfile</a>. <em>(2.2 as of this post)</em>
</ul>
<p><span id="more-29"></span><br />
First, make sure you even <em>have</em> Ant installed. The easiest way to do this is just to check the version:</p>
<pre><code>
$ ant -version
$ Apache Ant(TM) version 1.7.1 compiled on February 10 2010
</code></pre>
<p>Great! Keep track of which version you&#8217;re using now; we&#8217;ll compare version strings to verify our install once we&#8217;re done.</p>
<p>Now Ant is kind of buried in OS X; the <var>$PATH</var> variable points to a symlink which points to another symlink. To find out where ant <em>really</em> is, just follow the chain:</p>
<pre><code>
$ which ant
/usr/bin/ant
$ ls -la /usr/bin/ant
lrwxr-xr-x  1 root  wheel  22 Nov 11 18:04 /usr/bin/ant -> /usr/share/ant/bin/ant
$ ls -la /usr/share/ant
lrwxr-xr-x  1 root  wheel  14 Nov 11 18:04 /usr/share/ant -> java/ant-1.7.1
$ ls -la /usr/share/java/ant-1.7.1
total 40
drwxr-xr-x   8 root  wheel    272 Feb 27 12:32 .
drwxr-xr-x   8 root  wheel    272 Nov 11 18:04 ..
-rw-r--r--   1 root  wheel  15289 Feb 10  2010 LICENSE.txt
-rw-r--r--   1 root  wheel   1270 Feb 10  2010 NOTICE.txt
drwxr-xr-x   8 root  wheel    272 Feb 10  2010 bin
drwxr-xr-x   3 root  wheel    102 Feb 10  2010 docs
drwxr-xr-x  15 root  wheel    510 Feb 10  2010 etc
drwxr-xr-x  44 root  wheel   1496 Feb 27 12:09 lib
</code></pre>
<p>Gotcha! It looks like ant is hiding inside of the default Java directory, so blowing it away is probably a bad idea. Instead we&#8217;re going to throw the new version of ant into a common directory and update the symlink.</p>
<p>Copying the directory is easy:</p>
<pre><code>
$ cp -r ~/Downloads/apache-ant-1.8.2/ /Library/Ant-1.8.2
</code></pre>
<p>Now we need to break the existing symlink and recreate it, pointing to our new version of Ant. You&#8217;ll need to do this as root.</p>
<pre><code>
$ rm /usr/share/ant
$ sudo ln -s /Users/Shared/apache-ant-1.8.2  ant
$ Password: ********
</code></pre>
<p>And when we check our version string&#8230;</p>
<pre><code>
$ ant -version
$ Apache Ant(TM) version 1.8.2 compiled on December 20 2010
</code></pre>
<p>Excellent, the update&#8217;s done and we&#8217;re on the newer version. The next step is to get the FTP task working. This is just a matter of copying the Apache Commons Net library into Ant&#8217;s classpath. If you followed the previous steps, then your Ant classpath is <code>/Users/Shared/apache-ant-1.8.2/lib</code>.</p>
<pre><code>
$ cp ~/Downloads/commons-net-2.2/commons-net-2.2.jar /Users/Shared/apache-ant-1.8.2/lib/commons-net-2.2.jar
</code></pre>
<p>And that&#8217;s it! You should now be in automated deployment bliss. If you need to know how to actually <em>use</em> the FTP task, go check out the <a href="http://ant.apache.org/manual/Tasks/ftp.html">documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/02/ant-ftp-task-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rolling my own HTML5 Boilerplate</title>
		<link>http://www.blog.ninjascript.com/2011/02/rolling-my-own-html5-boilerplate/</link>
		<comments>http://www.blog.ninjascript.com/2011/02/rolling-my-own-html5-boilerplate/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 07:26:43 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=28</guid>
		<description><![CDATA[HTML5 Boilerplate has been generating a decent amount of buzz lately. OK, it&#8217;s nice. Really, really nice. So nice, in fact, that I abandoned my own project to create a project baseline. Instead I rolled my own custom boilerplate, and there was a lot to customize. You&apos;re all I ever wanted I&#8217;ve been meaning to [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> has been generating a decent amount of buzz lately. OK, it&#8217;s nice. Really, <em>really</em> nice. So nice, in fact, that I abandoned my own project to create a project baseline. Instead I rolled <a href="https://github.com/ninjascribble/SquareOne">my own custom boilerplate</a>, and there was a lot to customize.<br />
<span id="more-28"></span></p>
<h2>You&apos;re all I ever wanted</h2>
<p>I&#8217;ve been meaning to do this for a while. When I run into a problem I don&#8217;t know how to solve while working on a project, I like to create a new project to address just that problem. Doing so lets me focus on the new script without letting the larger project cloud my thought-process. It&#8217;s the equivalent of clearing off a workbench by swiping your arm across it.</p>
<p>But when you clear off a workbench, you want to clear it off fast! Anything else would detract from the problem-at-hand. When I wrote <a href="http://www.blog.ninjascript.com/2011/02/is-your-project-agile-ready/">An agile-ready checklist</a> I referred to this too: if you don&#8217;t have the ability to get something started and delivered quickly, then you have a process problem. In this case my wish list was pretty short: <strong>One script to:</strong></p>
<ul>
<li>Create a named project in my shared project directory that includes&#8230;
<li>&#8230;my usual directory structure with default .css and .js files.
<li>&#8230;<a href="jquery.com">jQuery</a>. Offline so I can work <em>sans interwebz</em>.
<li>&#8230;a unit testing framework, ready to go.
<li>&#8230;a pretty enough UI that I don&#8217;t get distracted trying to clean it up.
</ul>
<p>It&#8217;s really not that much when you think about it, and H5B delivers. </p>
<h2>&quot;delete-key friendly&quot;</h2>
<p>It delivers so well in fact, that it over-delivers. There&#8217;s a reason Paul Irish coined the phrase &#8220;delete-key friendly&#8221; within the list of H5B&#8217;s &#8220;awesome-er&#8221; features; this thing was meant to cover everything from inspiration to deployment, and comes with a bunch of server configuration templates, placeholders for developing jQuery plugins, styles for mobile devices&#8230; all of this had to go. In the heat of the moment, I&#8217;d rather not be tripping over any more cruft than I have to.</p>
<p>Although I did leave in a few things for later, hidden behind commented code, like the hooks for <a href="http://www.google.com/analytics/">Google Analytics</a>. No it&#8217;s not going to do me any good in a development environment, but I&#8217;ve been meaning to throw a few projects behind <a href="http://ninjascript.com">ninjascript.com</a>, just for the hell of it. Keeping GA commented in there just means I&#8217;m more likely to remember to turn it on at some point when it could be useful.</p>
<h2>Changing things up</h2>
<p>Just because I like to tinker, and if I didn&#8217;t do it now then I&#8217;d just waste time later, I also made a few additions of my own. The low-hanging fruit just meant upgrading jQuery and writing some custom CSS so that my new projects weren&#8217;t completely bare. The more interesting things came in the form of a <a href="https://github.com/ninjascribble/SquareOne/blob/master/build.xml">build script</a>.</p>
<p>H5B does come with its own shell script for creating new projects, but it&#8217;s very utilitarian: Create a project directory and copy files over to it. One of my own criteria was that the script create new projects in <em>my shared project directory</em>. I was going to have to change that script anyway, but I wanted to give my new projects some identity too, so in the .html, .css and .js files I added some tokens. The whole thing is ridiculously simple:</p>
<pre><code>
$> ant
$> ...Give it a name:
$> ...What's it about?:
</code></pre>
<p>And bam! you&#8217;re done. The build script reads in a few properties so that I can configure my project path and the token values:</p>
<pre><code>
author.name=Scott Grogan
author.site=http://ninjascript.com
dest.dir=/Users/scottgrogan/Projects
</code></pre>
<h2>Next steps</h2>
<p>If the links haven&#8217;t given it away, I chucked this project onto GitHub: <a href="https://github.com/ninjascribble/SquareOne">ninjascribble/SquareOne</a>. Check it out, send feedback, etc&#8230; I&#8217;ll be updating it as I go. Next up: H5B&#8217;s build.xml feels ridiculously cluttered. I like keeping things simple: clean, test, compile, deploy. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/02/rolling-my-own-html5-boilerplate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Imagining better bill-pay</title>
		<link>http://www.blog.ninjascript.com/2011/02/imagining-better-bill-pay/</link>
		<comments>http://www.blog.ninjascript.com/2011/02/imagining-better-bill-pay/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 23:57:13 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=21</guid>
		<description><![CDATA[I pay my bills on the same Saturday of every month, and every month sees the same routine: A frustrating experience with one (or all) of the websites that espouse &#8220;easy online payments,&#8221; only to wind up calling the company and paying by phone. While I appreciate any business that wants to keep my confidential [...]]]></description>
				<content:encoded><![CDATA[<p>I pay my bills on the same Saturday of every month, and every month sees the same routine: A frustrating experience with one (or all) of the websites that espouse &#8220;easy online payments,&#8221; only to wind up calling the company and paying by phone. While I appreciate any business that wants to keep my confidential information secure, requiring an increasingly convoluted combination of letters, numbers and special characters only ensures that I will find it necessary to write my password down somewhere and undermine the very security they hope to impose.</p>
<p>I have a technical background, and I <em>know</em> I&#8217;m not the only one who suffers this grind month after month. It&#8217;s time that bill payment systems see a user-experience overhaul, and I&#8217;ve got a few ideas:<br />
<span id="more-21"></span></p>
<h2>Adopt a pay-by-phone-like process</h2>
<p>While navigating a phone tree does come with its own set of frustrations, I find the process much easier to deal with. For starters, when I pay by phone I usually need only three identifying pieces of information: </p>
<ul>
<li><strong>My account number</strong>
<li><strong>zip code</strong>
<li><em>and sometimes</em> <strong>the last four digits of my social security number</strong>
</ul>
<p> No passwords or security questions, and with good reason: The automated phone system doesn&#8217;t allow me to do anything but pay my bill!</p>
<p>Take, for example, the sign in page for <a href="https://login.comcast.net/login">Comcast</a>. Along with fields for a username and password, I&#8217;m presented with this:</p>
<p><img src="http://www.blog.ninjascript.com/wp-content/uploads/2011/02/comcast-id-for-you.png" alt="Comcast offers premium TV and movie streaming, home entertainment planning and management, and the ability to control my DVR from anywhere, but all I want to do is pay my bill!" title="Comcast offers premium TV and movie streaming, home entertainment planning and management, and the ability to control my DVR from anywhere, but all I want to do is pay my bill!"></p>
<p>Comcast offers some great features, and if I&#8217;m going to use them at all then I expect to have to sign in first. But none of these things have anything to do with paying my bill, and shouldn&#8217;t get in the way of my ability to do so. </p>
<h2>Let me use my email address as my username</h2>
<p>If a company <em>must</em> put their bill-pay feature behind authentication, then making password recovery as painless as possible should be a priority. If I&#8217;m only going to use the site once per month, then it&#8217;s reasonable to expect that I won&#8217;t remember the credentials I signed up with. </p>
<p>Companies can save their customers a lot of frustration by just allowing them to use an email address as their username. Every customer already has a unique one, they&#8217;re incredibly easy to remember, and if a customer forgets their password then a reset link can be sent directly to that email address.</p>
<h2>Let me decide how secure my password will be</h2>
<p>I&#8217;ll admit it. I use the same password for everything, with slight variations for sites I&#8217;d prefer to be a bit more secure. Nothing frustrates me more than when a company tries to impose a set of arcane rules upon my password creating process. Those rules only serve to ensure that I <em>will</em> forget my password the next time I try to log in. Keep it simple and let your customers use their own judgment. </p>
<h2>Security questions based on facts, not opinions</h2>
<p>Forming a set of security questions has become a pretty common practice for password recovery. I tend to like the ones that have a preformed list of questions from which to choose, but the quality of these questions are often, well&#8230; questionable. My favorite band changes weekly, as does my favorite color and even the memory of which of my many childhood pets was the first. None of these are &#8220;facts&#8221; in the sense of immutable identifying information that can be readily recalled.</p>
<p>Now I understand that forming security questions and keeping the answers on file can be tricky business. Customers get leery when asked for their mother&#8217;s maiden name, or any other information that might be used to identify them on a federal form. But the high school I graduated from, the degree I earned, and the color of my first bike are objective facts and impossible to change.</p>
<p>Making online payments can be a wonderful thing for both customers and the companies they&#8217;re paying, but &mdash;as with everything interactive on the web&mdash; user experience should always be of paramount concern. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/02/imagining-better-bill-pay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An agile-ready checklist</title>
		<link>http://www.blog.ninjascript.com/2011/02/is-your-project-agile-ready/</link>
		<comments>http://www.blog.ninjascript.com/2011/02/is-your-project-agile-ready/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 03:57:47 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=19</guid>
		<description><![CDATA[If you aren&#8217;t in a position to deploy working code on a regular schedule, then your project can&#8217;t really be called &#8220;agile.&#8221; Getting the team together regularly and taking a test-first approach to development are fantastic practices, and employing them is crucial to a successful agile team. Agile by definition, however, means being able to [...]]]></description>
				<content:encoded><![CDATA[<p>If you aren&#8217;t in a position to deploy working code on a regular schedule, then your project can&#8217;t really be called &#8220;agile.&#8221; Getting the team together regularly and taking a test-first approach to development are fantastic practices, and employing them is crucial to a successful agile team. Agile by definition, however, means being able to deploy recent updates to production frequently and regularly.</p>
<p>&#8220;Agile&#8221; is a bit of a buzzword these days, and one of the chief complaints I hear from developers working towards an agile methodology is the push to be immediately more productive while the infrastructure lags behind. Maybe the development and pre-prod environments are unstable, the process for deploying to production is slow or costly, or there isn&#8217;t an accepted standard for driving automated unit and acceptance tests. Whatever it is that&#8217;s slowing you down, fix it! The longer it waits, the worse it gets. Here&#8217;s my own checklist for deciding whether or not a project is ready to be called &#8220;agile.&#8221;<br />
<span id="more-19"></span></p>
<h2>Development and pre-prod environments are up and stable</h2>
<p>You would think this would be obvious, but I&#8217;ve worked on more than a few projects where the team and product owners were too excited to think about where it would live until they were ready to take it live. Depending on the size and structure of your organization, getting a production environment can be a lengthy process. I&#8217;ve seen production set-ups delayed for weeks because the request was given to IT during a maintenance period. Oops.</p>
<h2>An automated deployment task is in place</h2>
<p>Ideally deployment to production should happen at the press of a button. At my company we use <a href="http://www.anthillpro.com/html/default.html">AnthillPro</a>, but there are plenty of other deployment tools out there. The point? Make the process of shipping code as fast and painless as possible, so you don&#8217;t ever have an excuse not to go live.</p>
<h2>Automated testing is also in place</h2>
<p>Automated deployment and automated testing go hand-in-hand. Your unit and acceptance tests are your primary line of defense against production bugs, and just like deployment you want this process to be repeatable and as painless as it can be.</p>
<p>Please don&#8217;t misunderstand &mdash; I&#8217;m not saying that you must have 100% code coverage before you go live for the first time. But having a system in place makes writing them that much easier. Most Java projects incorporate <a href="http://www.junit.org/">JUnit</a> test suite, which is incredibly easy to integrate with ANT. Acceptance testing can be trickier if you aren&#8217;t already familiar with it. If your project sits behind authentication, then you may need to write a custom framework to bypass it.</p>
<h2>Happy, productive developers</h2>
<p>With the infrastructure taken care of up front, developers can spend more time focusing on the next big feature and less time worrying about the development tools. When working code gets released, everyone feels good &mdash; that should be all the reason you ever need to want to do it as often as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/02/is-your-project-agile-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bundling Javascript and CSS resources with Jawr</title>
		<link>http://www.blog.ninjascript.com/2011/02/bundling-javascript-and-css-resources-with-jawr/</link>
		<comments>http://www.blog.ninjascript.com/2011/02/bundling-javascript-and-css-resources-with-jawr/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 06:31:48 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[usability]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=5</guid>
		<description><![CDATA[<h2>What is Jawr?</h2>
On the surface, Jawr a resource bundling library for Java web apps with an incredibly confusing name (try saying "Put the Jawr JAR in the lib dir" a few times out loud...). The <a href="http://jawr.java.net/">project website</a> has this to say about it:
<blockquote>Jawr is a tunable packaging solution for Javascript and CSS which allows for rapid development of resources in separate module files. Developers can work with a large set of split javascript files in development mode, then Jawr bundles all together into one or several files in a configurable way.</blockquote>
Jawr allows you to keep your Javascript and CSS files separated and organized within a project, while still taking advantage of resource minification, concatenation, compression and caching (ie. <em>bundling</em>).
<h2>But why should I bundle my resources anyway?</h2>
Because for every shiny presentation effect there's an HTTP request. The project relies on a number of data visualization libraries, some of which are pretty gigantic all on their own. The project is behind authentication and not exactly intended for public consumption, but I can at least show off some screenshots pulled from the Firebug net tab]]></description>
				<content:encoded><![CDATA[<p>On the surface, Jawr is a resource bundling library for Java web-apps with an incredibly confusing name (try saying &#8220;Put the Jawr JAR in the lib dir&#8221; a few times out loud&#8230;). The <a href="http://jawr.java.net/">project website</a> has this to say about it:</p>
<blockquote><p>Jawr is a tunable packaging solution for Javascript and CSS which allows for rapid development of resources in separate module files. Developers can work with a large set of split javascript files in development mode, then Jawr bundles all together into one or several files in a configurable way.</p></blockquote>
<p>Jawr allows you to keep your Javascript and CSS files separated and organized within a project, while still taking advantage of resource minification, concatenation, compression and caching (ie. <em>bundling</em>).</p>
<h2>But why should I bundle my resources anyway?</h2>
<p>Because for every shiny presentation effect there&#8217;s an HTTP request, and sometimes those requests are BIG. I&#8217;ve been recently working on a project that pulls in a number of Javascript data visualization libraries, none of which come cheap. The project is behind authentication and not exactly intended for public consumption, but here are some screenshots I pulled from Firebug&#8217;s net tab.<br />
<span id="more-5"></span><br />
First the CSS:</p>
<p><img title="Uncompressed CSS: 5 requests @ 40k" src="http://www.blog.ninjascript.com/wp-content/uploads/2011/02/02-css-uncompressed.png" alt="Uncompressed CSS: 5 requests @ 40k" /></p>
<p>5 resources weighing in at 40k. Not terrible, but that&#8217;s a lot of requests for just the CSS. Every single one adds overhead that stands between the report and its intended viewer. Since this is a screenshot from my development environment, the timeline may be a bit misleading, but in this case loading these resources probably won&#8217;t take up enough time  to be any real concern.</p>
<p>The Javascript on the other hand&#8230;</p>
<p><img title="Uncompressed Javascript: 6 requests @ 340k" src="http://www.blog.ninjascript.com/wp-content/uploads/2011/02/02-js-uncompressed.png" alt="Uncompressed Javascript: 6 requests @ 340k" /></p>
<p>6 resources and 340k! Even on a fast connection this is going to take a few seconds to come down the wire. These requests are intentionally made <em>after</em> the rest of the page has loaded, but a good chunk of the functionality relies on these scripts; until they load the visitor is going to be staring at a sweet-looking UI without any real way to interact with it. Worse still, as the project grows so grows the resources; bundling just became <em>important</em>.</p>
<h2>Jawr to the rescue</h2>
<p>There are plenty of ways to manage the size of your resources:</p>
<ul>
<li>Concatenation, or smooshing all of your resources into a single massive file.</li>
<li>Minification, aka &#8220;hope you weren&#8217;t planning to make any changes to that script&#8221;.</li>
<li>Compression, which often means run-time decompression. I&#8217;m talking <a href="http://dean.edwards.name/weblog/2007/04/packer3/">Packer</a>, not GZip (which is awesome).</li>
</ul>
<p>For the most part these are fantastic in a production environment, but while I don&#8217;t have the benefit of your own experience to draw upon, in my experience the only kind of project that isn&#8217;t constantly being reworked and redeployed is a dead one. While Jawr is one of <em>many</em> ways to achieve the best of both worlds &amp;mdash&amp; a clean development environment and compact production resources — I really appreciate how simple it is to configure and maintain.</p>
<h3>Configuring the servlets</h3>
<p>Every CSS and Javascript request needs to go through Jawr in order to take advantage of bundling. When a request is made, Jawr will decide (with help from your config file) whether to respond directly with the resource, or to perform an operation on it first.</p>
<pre><code><servlet>
  <servlet-name>JavascriptServlet</servlet-name>
  <servlet-class>net.jawr.web.servlet.JawrServlet</servlet-class>
  <init-param>
    <param-name>configLocation</param-name>
    <param-value>/jawr.properties</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
 
<servlet>
  <servlet-name>CSSServlet</servlet-name>
  <servlet-class>net.jawr.web.servlet.JawrServlet</servlet-class>
  <init-param>
    <param-name>configLocation</param-name>
    <param-value>/jawr.properties</param-value>
  </init-param>
  <init-param>
    <param-name>type</param-name>
    <param-value>css</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
 
<servlet-mapping>
  <servlet-name>JavascriptServlet</servlet-name>
  <url-pattern>*.js</url-pattern>
</servlet-mapping>
 
<servlet-mapping>
  <servlet-name>CSSServlet</servlet-name>
  <url-pattern>*.css</url-pattern>
</servlet-mapping></code></pre>
<h3>Configuring jawr.properties</h3>
<p>You can set up as many bundles as you need here, eg. a core bundle that is used throughout your project and a few context-specific bundles if you need them. Jawr lets you make considerations for which resources should be bundled in which order and which resources should be spared the compression algoritm. Depending on how complicated your bundles are, this file can get pretty hairy. For clarity, the following shows only the configuration for my project&#8217;s core Javascript bundle. There&#8217;s plenty of documentation to follow at <a href="http://jawr.java.net/docs/custom_bundles.html">http://jawr.java.net/docs/custom_bundles.html</a>.</p>
<p>One thing to note is that every request for a bundle will be routed here. When debugging in your development environment, it&#8217;s best to flip the <code>jawr.debug.on</code> property to <code>true</code>. Jawr will then serve up all of the uncompressed resources that <em>would</em> have appeared in the bundle.</p>
<pre><code># Common properties
jawr.debug.on = false
jawr.gzip.on = true
jawr.gzip.ie6.on = false
jawr.charset.name = UTF-8

# This is the root dir for all our javascript resources.
jawr.js.bundle.basedir = /js

# Define the core set of scripts for use across the platform.
jawr.js.bundle.core.id = /bundles/core.js
jawr.js.bundle.core.composite = true
jawr.js.bundle.core.global = true
jawr.js.bundle.core.child.names = jquery,dependencies

# No need to compress pre-compressed scripts, just add them to the bundle.
jawr.js.bundle.jquery.mappings = /js/libs/jquery-1.4.4.min.js,\
                   /js/libs/jquery-ui-1.8.9.custom.min.js
jawr.js.bundle.jquery.bundlepostprocessors = none

# These guys are part of the core bundle too...
jawr.js.bundle.dependencies.mappings = /js/libs/OpenAjaxManagedHub-core.js,\
                   /js/libs/IntelReports/IntelReports.js</code></pre>
<h3>Adding Jawr to the JSPs</h3>
<p>Jawr comes with a small taglib for use inside of an application&#8217;s JSP files. The <code>jwr:script</code> and <code>jwr:style</code> tags will interpret Expression Language natively, and simply refer to a bundle definition within <code>jawr.properties</code> before handling the request.</p>
<pre><code><@ taglib uri="http://jawr.net/tags" prefix="jwr" %>
<jwr:script src="/bundles/${report.resourcePath}.js"/>
<jwr:style src="/bundles/${report.resourcePath}.css"/></code></pre>
<h2>The payoff!</h2>
<p>With bundling enabled, the application sees a dramatic benefit.</p>
<p><img title="Compressed CSS: 2 requests @ 6k" src="http://www.blog.ninjascript.com/wp-content/uploads/2011/02/02-css-compressed1.png" alt="Compressed CSS: 2 requests @ 6k" /></p>
<p>CSS Just under 6k! It wasn&#8217;t huge before, but it&#8217;s certainly not causing any trouble now. In fact this same project is using sprites that come in larger than the CSS that drives them. Maybe something to investigate another time!</p>
<p>And the Javascript?</p>
<p><img title="Compressed Javascript: 2 requests @ 60k" src="http://www.blog.ninjascript.com/wp-content/uploads/2011/02/02-js-compressed1.png" alt="Compressed Javascript: 2 requests @ 60k" /></p>
<p>60k is certainly a reasonable size for some pretty large libraries, and represents an incredible more than 80% savings over the uncompressed example. Jawr does allow you to specify which minification method to use, and it&#8217;s certainly worthwhile to play around and see which options work best for your project. These figures came from a quick default integration, and I couldn&#8217;t be happier with the way things turned out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/02/bundling-javascript-and-css-resources-with-jawr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On maps, tweets and tablets&#8230;</title>
		<link>http://www.blog.ninjascript.com/2011/01/on-maps-tweets-and-tablets/</link>
		<comments>http://www.blog.ninjascript.com/2011/01/on-maps-tweets-and-tablets/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 20:52:50 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.blog.ninjascript.com/?p=26</guid>
		<description><![CDATA[A few days ago Hubspot published a simple choropleth map visualization of Twitter usage per capita across the United States. The map assigns a percentage value above or below the national average tweet-rate to each state. Edward Tufte would be quick to point out that neither the visualization nor its corresponding blog post contain two [...]]]></description>
				<content:encoded><![CDATA[<p>A few days ago <a href="http://hubspot.com/products">Hubspot</a> published a simple choropleth map visualization of <a href="http://blog.hubspot.com/blog/tabid/6307/bid/7905/Twitter-Usage-Per-Capita-How-States-Compare-Infographic.aspx#ixzz1AB7LmTsj">Twitter usage per capita across the United States</a>. The map assigns a percentage value above or below the national average tweet-rate to each state.</p>
<p>Edward Tufte would be quick to point out that neither the visualization nor its corresponding blog post contain two bits of concrete information: The actual national average tweet-rate, and how it compares to previous years. Without these vital metrics, the conclusion (&#8220;&#8230;Twitter will be an especially important tool if you are trying to grow your business&#8230;&#8221;) is a bit suspect, though <a href="http://bits.blogs.nytimes.com/2009/07/15/hacker-exposes-private-twitter-documents/?hpw.">the $150M (projected) they made in 2010</a> tells me they&#8217;re doing OK.</p>
<p>That minor quibble notwithstanding, the map does call out a few surprising conclusions (Massachusetts is one of the top three? Really?). I&#8217;d really love a time-series of these maps over the last four years, just to see how much things have grown and changed.</p>
<p>Speaking of Twitter, it dawned on me today that my own decline in Twitter usage links directly back to the acquisition of my iPad. Lets look at the crucial facts:</p>
<p>    * App-switching was non-existent for a good while post-launch.<br />
    * The iPad features a terrible, awful, horrible (sorry&#8230;) keyboard.</p>
<p>Don&#8217;t get me wrong, I&#8217;m sure there are thousands of happy iPad tweeters in the world, but I&#8217;m not one of them. Sadly though, because the <a href="http://www.flipboard.com/">Flipboard</a> app integrates with Twitter I *do* still post retweets and article links pretty regularly. Unwittingly I am a cog in the information proliferation machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.ninjascript.com/2011/01/on-maps-tweets-and-tablets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
