<?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>BarneyBlog &#187; ajax</title>
	<atom:link href="http://www.barneyb.com/barneyblog/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Mon, 02 Mar 2020 13:20:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adobe, Mobile Flash Player, JavaScript, etc.</title>
		<link>https://www.barneyb.com/barneyblog/2011/11/10/adobe-mobile-flash-player-javascript-etc/</link>
		<comments>https://www.barneyb.com/barneyblog/2011/11/10/adobe-mobile-flash-player-javascript-etc/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 18:28:55 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=1743</guid>
		<description><![CDATA[Before you click over this because you know me as a Flash hater, give me two seconds.Â  That's not what this post is about.Â  It's about a larger issue.Â  It's about how awesome it is to be a web developer these days.
Ten years ago, being a web developer sucked.Â  Deployment was easy (rsync to production [...]]]></description>
			<content:encoded><![CDATA[<p>Before you click over this because you know me as a Flash hater, give me two seconds.Â  That's not what this post is about.Â  It's about a larger issue.Â  It's about how awesome it is to be a web developer these days.</p>
<p>Ten years ago, being a web developer sucked.Â  Deployment was easy (rsync to production and done), but the tooling available to us was dismal.Â  And I mean crying-naked-in-a-snowstorm dismal.Â  Browsers were inconsistent, their built-in programming environment (read JavaScript) was reasonably functional but horridly slow, and hardware wasn't beefy enough to deal with scripting languages for hard-core number crunching.</p>
<p>But we had the Flash Player.Â  Flash provided an environment that beat all three of those problems, and beat them soundly.Â  It was consistent across browsers and operating systems, used a similar language to what we were used to (both JavaScript and ActionScript are ECMAScript implementations), and it let the developer compile the script into something a little lower level to run in a dedicated VM on the user's machine which meant it was faster.Â  Of course, Flash is an animation toolkit, but we figured out how to bastardize it with the single-frame movie with a include-and-stop script in it so we could build applications entirely with script (like we wanted), but leverage the Flash player to actually run them.Â  Not to mention the rich support for visual stuff.Â  All this led to the concept of a RIA (Rich Internet Application).Â  Something similar to what we had on the desktop, but deployed to the web with all the benefits (and some drawbacks) that has.</p>
<p>Then browsers got their act together.Â  We started seeing a unifying focus on application development with the browser as the environment.Â  People got serious about fast JavaScript runtimes.Â  Standards were written (e.g., CSS2/3, Canvas) and largely adhered to.Â  And hardware got faster.Â  JavaScript application frameworks (EXT, YUI, GWT, etc.) showed up to leverage all that, and now it was possible to build RIAs using standards supported by a wide array of vendors.</p>
<p>In order to compete with this, Adobe released Flex, which is an application development framework for deploying to Flash Player.Â  It was horridly expensive, difficult to work with, had all kinds of implementation problems, but was better than what you got with JavaScript.Â  For a while.Â  Unfortunately a single software company, even one of the largest in the world, couldn't hope to compete with the widespread interest and momentum around browser-native RIA development.Â  Flex died as a web application framework pretty much before it was released.Â  Which isn't to say it wasn't used (it was and still is), but the browser RIA juggernaut crushed it like a bug.</p>
<p>Then we saw the huge surge in mobile devices.Â  It started with smartphones and now includes tablets and e-readers of various form factors.Â  Fortunately for both consumers and manufacturers, the web wasn't new, so they were able to jump right on top of all the standards and browser capabilities which had been created for the desktop.Â  A huge market segment opened up for web application developers and browser-native was reasonable right out of the box.</p>
<p>Adobe again tried to compete by creating Mobile Flash Player, but the benefits of Flash Player are small on new mobile devices, especially considering that so much of a mobile device experience is through web-connected native applications, not traditional web applications.Â  And here we have Adobe's smartest move yet around Flash Player: killing it for the mobile market in favor of restructuring the ecosystem around using it as a development environment for native applications.</p>
<p>Unfortunately, I don't think it's going to matter because Flash is still really slow and heavy and it's not really that much better to develop with than the truly native dev kits.Â  Yes, it offers the promise of cross-platform deploy, but just as Java demonstrated 10-15 years ago, that isn't much of a selling point for a single application.Â  People expect not just native execution, they expect native idioms, which means you have to develop for a specific platform, even if you're using a cross-platform toolkit.</p>
<p>So where does that leave us?Â  As consumers it leaves us in a great spot: there are lots of ways developers can deliver engaging applications to us, on all our devices.Â  As developers it leaves us in a weird spot: we're stuck with being either web or native developers, with Flash now trying to occupy a sort of middle ground (develop web-style, deploy native).Â  On the desktop I think Flash (via AIR) holds some promise, but ultimately I don't think it'll last.Â  The platform just isn't compelling enough to justify the dedication it requires to use it.Â  Java was designed for very much the same purpose as AIR, and virtually no one uses it.Â  Java moved almost entirely server side, something which Flash isn't likely to do.</p>
<p>Most interesting is the PhoneGap/Titanium/etc. movement which is very much paralleling the browser resurgence I talked about earlier.Â  Huge communities of people are working to take all the skills we have as web application developers and give us a build process to take web-ish apps and compile them into native applications, in much the same way Adobe has use AIR to compile Flash into native apps.Â  However, I think Flash is going to lose in exactly the same way, and for exactly the same reasons, as it lost in the browser.</p>
<p>Bottom line, if you use the web or a web-connected device (read: everybody) the world is going to be glorious in a couple years and only get better.Â  If you're a developer trying to work in that space, you need to learn browser technologies.Â  It's the way of the future.Â  Flash had it's run, but it's been on the way out for a long while.Â  It'll stick around, just like COBOL and Fortran have, but without an alternative path like Java ended up taking it isn't going to stay relevant to mainstream developers.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2011/11/10/adobe-mobile-flash-player-javascript-etc/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tag Hierarchies</title>
		<link>https://www.barneyb.com/barneyblog/2008/12/10/tag-hierarchies/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/12/10/tag-hierarchies/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 19:56:41 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=564</guid>
		<description><![CDATA[About four and a half years ago I wrote a little event tracking app that accepts a timestamp and a list of tags, and then provides a pile of ways to report on the data.Â  Think Twitter, except a couple years earlier, and designed for consumption by software, not people, at least at the individual [...]]]></description>
			<content:encoded><![CDATA[<p>About four and a half years ago I wrote a little event tracking app that accepts a timestamp and a list of tags, and then provides a pile of ways to report on the data.Â  Think Twitter, except a couple years earlier, and designed for consumption by software, not people, at least at the individual event level.Â  The app's been working magically since then, and now that there are a few people using it I realized I needed to support tag hierarchies.</p>
<p>The specific use case in question is aggregate reporting.Â  Say you track what you eat, and then you want to get a report of how often you eat vegetables.Â  To this point you've had two choices: retag all the events with 'celery', 'corn', 'carrots', etc. with an extra 'vegetable' tag, or write your report to OR together all the different veggies (remembering to update it every time you eat a new one for the first time).</p>
<p>On the flip side, if you just have a hierarchy of tags, you can drop all those tags underneath the 'vegetable' tag and then report on 'vegetable' directly, which has the implicit meaning of "itself and all it's descendants".Â  This is obviously much more desirable.</p>
<p>However, overlying a hierarchy is not without problems.Â  Tags are inherently free-form, and this app is no exception.Â  As such, the unique key needs to be the tag name by itself, not the combination of the tag name and it's parent.Â  So the solution I adopted is to expose tags in a flat structure, excepting in the actual hierarchy editor (for which I used the fantastic <a href="http://www.extjs.com/products/extjs/">ExtJS</a> <a href="http://www.extjs.com/deploy/dev/examples/tree/reorder.html">Tree Control</a>), and a slight tweak to the querying language.</p>
<p>Previously, you searched for events using a "tag:celery" style query.Â  With no hierarchy, that matched exactly the celery tag.Â  With a hierarchy, the semantics have changed slightly to the celery tag or any of it's descedants.Â  If you want the old behaviour, you'd use "tag:=celery".</p>
<p>Behind the scenes, I'm using nested sets for storage which makes those descendant queries lightning fast, though I ran into some interesting issues because there is only one storage table for all tags across all users, and each user's tag tree is potentially multi-rooted.Â  Neither are inherently difficult to deal with, but both were new problems and required a bit of reworking to my treemanager component.</p>
<p>All in all, the process was really painless, and I'm quite pleased at how transparent the overlay of hierarchy ended up being to the general functioning of the system.Â  In particular, ExtJS was a dream to work with.Â  It's fast, easy to use, easy to develop with, paired quite nicely with jQuery (what drives the rest of the app), and ended up requiring less than 70 lines of code to create the control, do lazy loading of children, add new nodes to the tree, reorder and rename nodes, and do all the backend calls to update the DB as needed.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/12/10/tag-hierarchies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery&#039;s Autocomplete&#039;s Undocumented source Option</title>
		<link>https://www.barneyb.com/barneyblog/2008/11/22/jquerys-autocompletes-undocumented-source-option/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/11/22/jquerys-autocompletes-undocumented-source-option/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 05:14:37 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=552</guid>
		<description><![CDATA[Yesterday I replaced an instance of my ComboBox widget with a jQuery Autocomplete.Â  A sad day it was.Â  However, I saved a JS file and a few K of download, so it was worth it.Â  Unfortunately, it's missing a fairly important bit of functionality: the ability to order the list of options.
If you're doing an [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I replaced an instance of my <a href="http://www.barneyb.com/barneyblog/projects/combobox/">ComboBox</a> widget with a <a href="http://jquery.com/">jQuery</a> Autocomplete.Â  A sad day it was.Â  However, I saved a JS file and a few K of download, so it was worth it.Â  Unfortunately, it's missing a fairly important bit of functionality: the ability to order the list of options.</p>
<p>If you're doing an Ajax-based complete, you can obviously order the options server-side and jQuery will happily spit them out in the same order.Â  In my case, however, the list of choices is static and fully known in the client.Â  jQuery only provides options for "url" (the URL to request for options) and "data" (a static array of options).Â  There's no half-way, where you can supply a function to return for the current term.</p>
<p>However, after spending a while digging around inside the internals of the widget, I discovered the undocumented "source" option (and it's complement, the "parse" option).Â  It's a function that will be called to get the options for the current term.Â  However, it seems to be undocumented, and is pretty tightly bound to the internal implementation of the widget.Â  Specifically, your return value structure has to be the same as the structure returned by the internal "parse" method.Â  Note this is NOT the 'parse' option I mentioned above.</p>
<p>If you don't supply data or a URL, the function passed as "source" will be invoked, and it's result will be either passed through the function passed as "parse" (if there is one), or returned directly.Â  That result must be an array of objects that represent the options.Â  Each object must have "data", "value", and "result" keys.Â  The first is an array of row data (passed as "row" to various callbacks), the second is the display value (what would come back from "formatItem"), and the third is the result value (what would have come back from "formatResult").</p>
<p>Mess though this is, it does let you execute arbitrary code to build the option list, including supplying a custom order, which is what I needed.Â  More specifically, I wanted to order tags that began with the search value before those that contained the search value in the middle.Â  Here's my code, just for reference.Â  "tagList" is an array of strings that are available for selection and the "tag" argument is the current value to be autocompleted.</p>
<pre>jQuery("selector").autocomplete({
  source: function(<span style="color: #ff0000;">tag</span>) {
    var map = {
      first: [],
      internal: []
    }
    for (var i = 0; i &lt; <span style="color: #0000ff;">tagList</span>.length; i++) {
      var pos = <span style="color: #0000ff;">tagList</span>[i].toLowerCase().indexOf(tag.toLowerCase());
      if (pos &gt;= 0) {
        map[pos == 0 ? "first" : "internal"].push({
          data: [<span style="color: #0000ff;">tagList</span>[i]],
          value: <span style="color: #0000ff;">tagList</span>[i],
          result: <span style="color: #0000ff;">tagList</span>[i]
        });
      }
    }
    return map.first.concat(map.internal);
  },
  matchSubset: false <span style="color: #008000;">// this is important</span>
})</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/11/22/jquerys-autocompletes-undocumented-source-option/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The FlexChart Manifesto</title>
		<link>https://www.barneyb.com/barneyblog/2008/10/22/the-flexchart-manifesto/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/10/22/the-flexchart-manifesto/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 06:42:46 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=536</guid>
		<description><![CDATA[The current state of web applications is a fragmented mess.Â  HTML is still the standard approach, but dynamic data loading with Ajax and application embedding with Flash are both incredibly popular, particularly for data-heavy applications.
HTML is great because it's easy to build and well understood by user agents, but you lack drawing capabilities.Â  SVG addressed [...]]]></description>
			<content:encoded><![CDATA[<p>The current state of web applications is a fragmented mess.Â  HTML is still the standard approach, but dynamic data loading with Ajax and application embedding with Flash are both incredibly popular, particularly for data-heavy applications.</p>
<p>HTML is great because it's easy to build and well understood by user agents, but you lack drawing capabilities.Â  SVG addressed parts of that, and if XHTML ever gets adopted in any meaningful way SVG will see a resurgence.Â  The canvas element has stepped in, but it's not universally supported.</p>
<p>Flash is the other end of the spectrum: you have extreme customizability, but developing applications is significantly more work and requires people with a higher skill level than for HTML apps.Â  Flex, OpenLazlo, etc. attempt to ease the developer's pain, but it's still not nearly as easy as HTML.Â  Silverlight (Microsoft's Flash competitor) follows the same vein, though with the addition of binding to Microsoft's technology stack.Â  I'll only be refering to Flash from here out, because as far as I'm concerned here, they're basically equivalent.</p>
<p>Flash also has the significant downside that it's hard to go half way.Â  Applications tend to be either all Flash or all HTML.Â  Static HTML applications can add snippets of Ajax in an incremental fashion where they're best suited without going whole hog.Â  Of course, if you want to go whole hog with HTML, that can be a lot of work too.</p>
<p>But what does this have to do with FlexChart, you ask?</p>
<p>FlexChart provides a way for dynamic HTML applications to leverage the drawing capabilities of Flash in a nearly completely transparent way.Â  If you want to render a chart on a page in a static HTML app, you'll probably employ some server-side technology to build an image and embed that image in the HTML with the IMG tag.Â  But if you want to control the chart's appearance with JavaScript, you're in a bit of a bind, because you have to go server-side to generate a new image and then update the image source with the new URL.</p>
<p>Google Charts provides something of a solution for this problem, because the URL of the image implicitly causes a chart regeneration.Â  So you don't have to manually go server-side, it happens behind the scenes.Â  But as anyone who has worked with the API knows, it can be a bit of a bear to figure out all your data ranges, encode your data, lay out your axes and labels, compute bar widths, etc.Â  Plus, while the number of charts available is pretty good, they're fairly inflexible.Â  For instance, you can't plot a trend line across a column (vertical bar) chart.</p>
<p>FlexChart provides what I feel is a better solution for many applications.Â  It uses a simple XML dialect for specifying both chart structure and the data to display.Â  It leverages the Flex's charting engine to take care of all the chart layout tasks so you don't have to do that.Â  It's designed to be loaded once and draw multiple charts over the SWF's lifetime by passing it new XML descriptors via JavaScript (though it can also be used statically with descriptors from FlashVars).Â  Since it's Flash, it also has the ability to provide interaction with the user.Â  For example, when a user clicks a given data point on your chart, you can detect that with JavaScript and load a new drilled-down chart.Â  The tradeoff is that it's Flash, and while Flash has good penetration, it's significantly behind PNG support (what Google Charts uses), particularly on mobile devices.</p>
<p>As such, FlexChart addresses a narrow slice of the inability/reluctance to build hybrid HTML/Flash applications by providing a JavaScript-centric API for drawing rich charts.Â  Note that this API is not just for drawing static charts, you can register JavaScript functions for handling data tip rendering, click handling, and axis labeling.Â  This allows a very high level of interactivity that I've not seen replicated in any other charting package for HTML/JavaScript applications with similar browser support (or really at all).</p>
<p>Another significant advantage is the technology-neutral XML dialect that FlexChart uses.Â  There is absolutely nothing FlexChart-specific in the structure of the XML, so any charting engine could theoretically read and render the XML.Â  I'm currently in the initial stages of a Google Charts-backed implementation that does exactly that.Â  Yes, that means you can supply FlexChart XML to this new project and get back a Google Charts URL that displays the chart.Â  Obviously it won't be a complete implementation because of limitations in Google Charts (like the mixed line/bar chart issue), but for supported aspects it will be equivalent.Â  This will allow an application to render charts either as Flash (with rich interactivity) or as PNG images (for broad support) <em>without having to change the format used to describe the charts</em>.</p>
<p>Note that the XML descriptor language does NOT provide for the full gamut of capabilities that Flex's charting components have to offer.Â  Nor will it cover all that Google Charts has to offer.Â  The idea is that it provides a <em>simple</em> way to describe most common chart types, and do it in a rendering-neutral way.Â  I've also gone to great lengths to hide much of the complexity that Flex (and soon to be Google Charts) foists on chart developers.Â  For example, Flex forces you to create a huge number of redundant axis references when laying out complicated charts, but with the XML descriptor you can do it once at the top level.Â  In the other direction, Google Charts forces you to explicitly specify all your axis labels and their positions, but the XML descriptor is such that they can be figured out for you by the implementation.</p>
<p>As I alluded to above, if XHTML actually gains adoption and SVG makes a comeback, that's another very likely candidate.Â  I've used an SVG-based charting engine that I wrote five of six years ago on several applications (currently using Batik to conver the SVG to PNGs for display), so that would be another potential implementation.Â  There are several canvas-based charting engines as well, all of which could be potential targets.Â  Finally, there are preexisting XML-configured Flash-based charting packages (FusionCharts is one example).Â  Leveraging one of those packages from the unified XML dialect would come for the cost of some XSL templates.Â  The possibilities are quite promising.</p>
<p>FlexChart itself is only half of the puzzle.Â  Sure, it's greate to have nice charts in a HTML/JavaScript application, but the bigger picture is just as important.Â  Having a single way to describe charts across applications and rendering mechanisms is a huge win.Â  Even more useful is bridging the gap between HTML and Flash with a way to create hybrid applications, instead of people seeing them only as two alternatives.Â  This is a huge win for all web app developers.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/10/22/the-flexchart-manifesto/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Checkbox Range Selection Update</title>
		<link>https://www.barneyb.com/barneyblog/2008/05/12/checkbox-range-selection-update/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/05/12/checkbox-range-selection-update/#comments</comments>
		<pubDate>Mon, 12 May 2008 19:32:34 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=407</guid>
		<description><![CDATA[Just a little update to my checkbox range selection jQuery plugin to allow chaining.Â  I'd forgotten to return 'this' at the end of the function.Â  Here's the full source, including the mod:
(function($) {
  $.fn.enableCheckboxRangeSelection = function() {
    var lastCheckbox = null;
    var $spec = this;
    [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little update to my checkbox range selection jQuery plugin to allow chaining.Â  I'd forgotten to return 'this' at the end of the function.Â  Here's the full source, including the mod:</p>
<pre>(function($) {
  $.fn.enableCheckboxRangeSelection = function() {
    var lastCheckbox = null;
    var $spec = this;
    $spec.bind("click", function(e) {
      if (lastCheckbox != null &amp;&amp; e.shiftKey) {
        $spec.slice(
          Math.min($spec.index(lastCheckbox), $spec.index(e.target)),
          Math.max($spec.index(lastCheckbox), $spec.index(e.target)) + 1
        ).attr({checked: e.target.checked ? "checked" : ""});
      }
      lastCheckbox = e.target;
    });
    return $spec;
  };
})(jQuery);
</pre>
<p>You can check the <a href="http://www.barneyb.com/barneyblog/projects/jquery-checkbox-range-selection/">project page</a> as well, for full history and updates.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/05/12/checkbox-range-selection-update/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Prototype and jQuery</title>
		<link>https://www.barneyb.com/barneyblog/2008/05/07/prototype-and-jquery/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/05/07/prototype-and-jquery/#comments</comments>
		<pubDate>Thu, 08 May 2008 07:01:36 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=389</guid>
		<description><![CDATA[Since I discovered it a few years ago, I've been a big Prototype fan.Â  It's simple, and gets the job done with a minimum of fuss.Â  It's not without warts, of course.Â  I still occasionally forget to put 'new' in front of Ajax.Request, and some of the Ruby-like methods share their lineage's arcane naming.Â  When [...]]]></description>
			<content:encoded><![CDATA[<p>Since I discovered it a few years ago, I've been a big <a href="http://www.prototypejs.org/">Prototype</a> fan.Â  It's simple, and gets the job done with a minimum of fuss.Â  It's not without warts, of course.Â  I still occasionally forget to put 'new' in front of Ajax.Request, and some of the Ruby-like methods share their lineage's arcane naming.Â  When it was new, it was the best thing around, and while it now has competitors, it's certainly not lagging behind.</p>
<p>At work, however, <a href="http://jquery.com/">jQuery</a> has been adopted as the standard (and I've no power to change it).Â  The lack of the $() function is annoying; several times I've debated adding this function (or one of various similar ones) to our library:</p>
<pre>function $(id) {
  return jQuery("#" + id)[0];
}</pre>
<p>I haven't, of course, as it's not the jQuery way.Â  jQuery also lacks any sort of class assistance, so we still use the Prototype class framework for our class-based JS.Â  That seems to work fairly well, except for the fact that we have to use two frameworks where one could suffice.</p>
<p>jQuery is not without it's benefits, of course.Â  The plugin architecture is a nice aspect that Prototype didn't really offer an equivalent of.Â  It means the core stays lighter (good), but if you want additional functionality you're stuck managing files from a bunch of different projects (annoying).Â  Event handling is a bit more straightforward, in some ways.Â  "Magically" acting on collections of elements with a single call (i.e. no .each(function(o){&#8230;}) garbage) definitely makes for more readable code as well.</p>
<p>Because of this shift at work, I've been porting some of my personal apps over to jQuery as well.Â  I've actually been using a couple jQuery plugins (both self-written and external) for specific tasks for a while now, but not the core framework.Â  What I've found, however, is that jQuery can be prone to slow code.Â  To avoid a huge amount of extra work on the part of the JS interpreter, using temporary variables for jQuery objects is essential.Â  If you do strictly id-based queries, the degradation isn't huge, but if you do CSS-based queries, it can be significant.Â  With Prototype's focus on id-based queries (at least until $$() came about in 1.5), that was less of an issue.</p>
<p>This need to query a minimum number of times can provide a fair amount of complexity when you have more than a handful of closures hanging about and/or a dynamic DOM.Â  You end up doing a lot of state management work because you're, in effect, caching DOM lookups and have to ensure you never have stale cache.</p>
<p>Other than that issue and the lack of an equivalent to document.viewport, porting has been relatively painless.Â  Still very id heavy, so not leveraging jQuery as much as could be, but most of what I'm doing wouldn't benefit from other selectors.</p>
<p>Which one is better?Â  Hard to say.Â  jQuery seems to make you work harder to type less code, while Prototype seems to cost you a few more characters for a bit less density.Â  With the exception of Prototype's class support, their feature sets are fairly equivalent, especially with <a href="http://ui.jquery.com/">jQuery UI</a> now available to "compete" with <a href="http://script.aculo.us/">Scriptaculous</a>.Â  For the moment, I'm choosing to use jQuery on new stuff, but wishing for Prototype every few minutes.Â  Until I come up against some sort of significant wall, it'll probably stay that way, just to stick with the same tooling professionally and personally.Â  And over time it'll probably get better as the Prototype-ness fades from apps.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/05/07/prototype-and-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ajaxian on Prototype vs JQuery</title>
		<link>https://www.barneyb.com/barneyblog/2008/04/15/ajaxian-on-prototype-vs-jquery/</link>
		<comments>https://www.barneyb.com/barneyblog/2008/04/15/ajaxian-on-prototype-vs-jquery/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 15:33:37 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=379</guid>
		<description><![CDATA[Ajaxian posted a little blurb on benchmarking Prototype and jQuery today.  I've been a Prototype guy for years, but at the office we've gone from all-Prototype to all-jQuery, and performance degredation was one of the things I noticed.  I never did any actual benchmarking, just went by feel, but it's interesting to see [...]]]></description>
			<content:encoded><![CDATA[<p>Ajaxian posted a little blurb on <a href="http://ajaxian.com/archives/jquery-and-prototype-benchmarks">benchmarking Prototype and jQuery</a> today.  I've been a Prototype guy for years, but at the office we've gone from all-Prototype to all-jQuery, and performance degredation was one of the things I noticed.  I never did any actual benchmarking, just went by feel, but it's interesting to see that my perceptions were well founded.</p>
<p>Whether performance of JS libraries should be a huge determinant in picking one to use is up for grabs.  Unless the client-side is doing a hell of a lot of work, these days' computers have plenty of CPU hanging about unused.Â   However, in the past couple months we've spent a lot of time working around JS performance issues at the office.  I can't say that using Prototype instead of jQuery would have eliminated the bottlenecks, but clearly performance matters.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2008/04/15/ajaxian-on-prototype-vs-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript.  At Last.</title>
		<link>https://www.barneyb.com/barneyblog/2007/08/13/javascript-at-last/</link>
		<comments>https://www.barneyb.com/barneyblog/2007/08/13/javascript-at-last/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 05:15:49 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[gpsracr]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/08/13/javascript-at-last/</guid>
		<description><![CDATA[Working on gpsracr.com this evening, and whipped open my favorite chunk of JS: Prototype.  It just gets better all the time.  They've added support for automatically executing text that is returned from an Ajax.Request with an appropriate MIME type (like text/javascript), which means you don't even need result handlers.  Just dispatch to [...]]]></description>
			<content:encoded><![CDATA[<p>Working on gpsracr.com this evening, and whipped open my favorite chunk of JS: <a href="http://www.prototypejs.org/">Prototype</a>.  It just gets better all the time.  They've added support for automatically executing text that is returned from an Ajax.Request with an appropriate MIME type (like text/javascript), which means you don't even need result handlers.  Just dispatch to your URL with whatever parameters you need, and let CF emit back whatever JS should run as a result of the submission (error, failure, success, whatever).  Talk about sweet.</p>
<p>Now that might not sound like a big deal, but it really is.  I use Fusebox.  So all my links are parameterized with XFAs.  But XFAs are server-side.  Client-side JS (especially static JS in *.js files) can't really access XFAs very well, so URL building is a pain for remoting endpoints and/or hard context switches,  But if you're generating the JS server-side&#8230;.</p>
<p>The specific use case was a login form.  I want to "submit" it asynchronously and either display a "denied" message if there's a failure, or forward to the inside of the app if it succeeds.  Ordinarily, you'd have to submit the credentials, get some sort of status back from the server, and then use JS to do something with it.  Now I can just submit the credentials and let CF emit the JS that I want to execute as a result.  I love it.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2007/08/13/javascript-at-last/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Improved ComboBox Demo</title>
		<link>https://www.barneyb.com/barneyblog/2007/05/17/improved-combobox-demo/</link>
		<comments>https://www.barneyb.com/barneyblog/2007/05/17/improved-combobox-demo/#comments</comments>
		<pubDate>Thu, 17 May 2007 21:12:26 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/05/17/improved-combobox-demo/</guid>
		<description><![CDATA[After Koen (a coworker) pointed out that my online ComboBox demo was rather user-unfriendly (like how you just had to "know" to type an 'a' in the fields), I threw some instructions around it.  It's available at /web/widgets/, as before.  There's also a new distro at /web/widgets/widgets-b2231.zip, and the project page has been [...]]]></description>
			<content:encoded><![CDATA[<p>After Koen (a coworker) pointed out that my online ComboBox demo was rather user-unfriendly (like how you just had to "know" to type an 'a' in the fields), I threw some instructions around it.  It's available at <a href="/web/widgets/">/web/widgets/</a>, as before.  There's also a new distro at <a href="/web/widgets/widgets-b2231.zip">/web/widgets/widgets-b2231.zip</a>, and the <a href="http://www.barneyb.com/barneyblog/projects/combobox/">project page </a>has been updated as well.Â  The actual code is unchanged, only the demo file has been updated.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2007/05/17/improved-combobox-demo/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ComboBox Widget Update</title>
		<link>https://www.barneyb.com/barneyblog/2007/05/16/combobox-widget-update/</link>
		<comments>https://www.barneyb.com/barneyblog/2007/05/16/combobox-widget-update/#comments</comments>
		<pubDate>Thu, 17 May 2007 06:17:22 +0000</pubDate>
		<dc:creator>barneyb</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/05/16/combobox-widget-update/</guid>
		<description><![CDATA[I've been making tweaks to my ComboBox widget (first published in July 2005) in various apps of mine that use it, and figured it was time to publish an update.  You can download the archive at /web/widgets/widgets-b2218.zip, play with the online demo (which is just the expanded archive) at /web/widgets/, or visit the project [...]]]></description>
			<content:encoded><![CDATA[<p>I've been making tweaks to my ComboBox widget (<a href="/barneyblog/2005/07/09/dhtml-combobox-widget/">first published in July 2005</a>) in various apps of mine that use it, and figured it was time to publish an update.  You can download the archive at <a href="/web/widgets/widgets-b2218.zip">/web/widgets/widgets-b2218.zip</a>, play with the online demo (which is just the expanded archive) at <a href="/web/widgets/">/web/widgets/</a>, or visit the <a href="http://www.barneyb.com/barneyblog/projects/combobox/">project page</a> for most info.Â   I believe I've fixed every bug that people have brought to my attention, but if I missed something, let me know.</p>
<p>New and notable features (in no particular order):</p>
<ul>
<li>multiple delimited values (defaults to comma delimited)</li>
<li>the ESC key will now close the dropdown, if it's open</li>
<li>the TAB key will select the current value and move focus off the combobox</li>
<li>automatic hiding of SELECT, APPLET, and EMBED elements under the dropdown (for IE)</li>
<li>automatic setting of autocomplete="off"</li>
<li>changed to update only ever 250ms, rather than on every key press, which greatly reduces needless churn with JS remoting-based dropdowns</li>
<li>added "Loading &#8230;" message while waiting for dropdown values (for JS remoting-based dropdowns)</li>
<li>removal of already-selected items from the dropdown (only useful for multi-select)</li>
<li>added wrapping with the arrow keys (pressing 'up' when the first item is selected will move the selection to the last item)</li>
<li>support for arbitrary HTML in the dropdown values that will be stripped to create the actual form field value</li>
</ul>
<p>There are a few known issues:</p>
<ul>
<li>if your dropdown is larger than it's allowed side, scrollbars will appear, but the scrolling won't reset when new items are loaded</li>
<li>untested on IE aside from a few spot checks.  However, except for the hiding of SELECT/APPLET/EMBED elements (which is fixed), I've not received any IE-specific complaints, so I'd say it's pretty sound.</li>
<li>documentation is somewhat lacking.</li>
</ul>
<p>I'm sure I'm missed some, but those are the high points.  As always, it's MIT licensed so you can basically do whatever.  If you find it useful (or think it's a piece of garbage), I'd love to hear about it.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.barneyb.com/barneyblog/2007/05/16/combobox-widget-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
