<?xml version="1.0"?>

<rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
>

<channel rdf:about="http://simon.incutio.com/syndicate/dhtml/rss1.0">
  <title>DHTML and Javascript</title>
  <link>http://simon.incutio.com/</link>
  <description>Simon Willison's DHTML and Javascript cateory</description>
  <language>en-uk</language>
  <webMaster>simon@incutio.com</webMaster>
  <items>
    <rdf:Seq>
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/11/09/tamarin" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/06/26/libraries" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/05/18/yahooui" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/05/01/speaking" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/03/07/etech" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/02/14/ui" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2006/01/20/escape" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/12/16/json" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/10/05/canvas" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/09/17/monkeyfun" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/09/11/firefox15" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/07/20/vulnerability" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/06/06/wikipedia" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/06/03/book" />
      <rdf:li rdf:resource="http://simon.incutio.com/archive/2005/05/24/fixing" />
    </rdf:Seq>
  </items>
</channel>

<item rdf:about="http://simon.incutio.com/archive/2006/11/09/tamarin">
  <title>Tamarin</title>
  <description>&lt;p&gt;On Tuesday, the Mozilla Foundation and Adobe &lt;a href=&quot;http://www.mozilla.com/en-US/press/mozilla-2006-11-07.html&quot; title=&quot;Adobe and Mozilla Foundation to Open Source Flash Player Scripting Engine&quot;&gt;announced&lt;/a&gt; the &lt;a href=&quot;http://www.mozilla.org/projects/tamarin/&quot;&gt;Tamarin project&lt;/a&gt;, an open-source ECMAScript virtual machine based on the ActionScript engine used by Flash Player 9.&lt;/p&gt;

&lt;p&gt;Frank Hecker's &lt;a href=&quot;http://www.hecker.org/mozilla/adobe-mozilla-and-tamarin&quot; title=&quot;Adobe, Mozilla, and Tamarin&quot;&gt;overview&lt;/a&gt; of what this means is useful, but &lt;a href=&quot;http://lxr.mozilla.org/mozilla/source/js/tamarin/core/avmplus.h#40&quot;&gt;the Tamarin source code itself&lt;/a&gt; provides this interesting piece of historical insight:&lt;/p&gt;

&lt;blockquote cite=&quot;http://lxr.mozilla.org/mozilla/source/js/tamarin/core/avmplus.h#40&quot;&gt;
&lt;p&gt;AVM+ is the ActionScript Virtual Machine&lt;/p&gt;

&lt;p&gt;AVM+ offers an order of magnitude performance increase over
the &quot;Classic AVM&quot; in Flash Player 7.  Our performance target is 10X.&lt;/p&gt;

&lt;p&gt;AVM+ implements ActionScript 3.0, the new version of the ActionScript
language that is compliant with the ECMAScript Edition 4 standard.&lt;/p&gt;

&lt;p&gt;AVM+ is also built for modularity.  It will be part of the Flash Player,
but is a self-contained module which can be incorporated into other
programs with ease.  It may also be submitted to the ECMA standards
organization as a reference implementation of ECMAScript Edition 4.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adobe's reputation for solid engineering shines through here - it seems that what is now Tamarin was designed for integration with other applications from the very start.&lt;/p&gt;

&lt;p&gt;The most important thing we can expect from this is a serious improvement in JavaScript performance in the Mozilla family of products, thanks to Tamarin's &lt;acronym title=&quot;Just In Time&quot;&gt;JIT&lt;/acronym&gt; compiler that can convert ECMAScript bytecode to machine code at runtime. JavaScript/Ajax applications will run faster, and the Mozilla applications themselves will perform better as much of their UI is written in JavaScript and XUL.&lt;/p&gt;

&lt;p&gt;This performance boost will benefit other applications as well. Tamarin is being integrated with &lt;a href=&quot;http://en.wikipedia.org/wiki/SpiderMonkey&quot;&gt;SpiderMonkey&lt;/a&gt;, which is used in a variety of applications such as the &lt;a href=&quot;http://widgets.yahoo.com/&quot;&gt;Yahoo! Widget Engine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Reading through Brendan Eich's technical overview of &lt;a href=&quot;http://weblogs.mozillazine.org/roadmap/archives/2006/10/mozilla_2.html&quot;&gt;Mozilla 2&lt;/a&gt;, it looks like the Mozilla team also plan on taking advantage of this performance boost to move code from C++ to JavaScript 2 in many places, simplifying their code base and reducing the likelihood of security flaws in the code.&lt;/p&gt;

&lt;p&gt;Even in these buzzword filled days of Ajax and Web 2.0, JavaScript is still seen as a poor cousin to so-called &quot;real&quot; programming languages. With a high performance open-source VM like Tamarin available, maybe more developers will start to re-examine JavaScript's role outside the browser.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/11/09/tamarin</link>
  <dc:subject>Mozilla, DHTML and Javascript</dc:subject>
  <dc:date>2006-11-09T12:24:45-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/06/26/libraries">
  <title>Notes on JavaScript Libraries</title>
  <description>&lt;p&gt;&lt;a href=&quot;http://www.vivabit.com/atmedia2006/&quot;&gt;@media 2006&lt;/a&gt; was a blast. Great talks, great people and some of the highest production values I've ever seen at a conference (check out &lt;a href=&quot;http://www.flickr.com/search/?q=atmedia2006+bags&quot;&gt;the bags&lt;/a&gt;!).&lt;/p&gt;

&lt;p&gt;I sat on the &lt;a href=&quot;http://www.vivabit.com/atmedia2006/sessions/#dom&quot;&gt;JavaScript Libraries: Friend or Foe?&lt;/a&gt; panel, with PPK, Dan Webb, Stuart Langridge and Cameron Adams chairing. It was my first participation in a panel and I really enjoyed it - I've always liked the Q&amp;amp;A bit of giving talks. JavaScript Libraries are an enormous topic but I felt we did them justice considering the time available. For the record, here are the key points that I wanted to get across:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Large JavaScript applications need some kind of library&lt;/strong&gt; - even if it's one built especially for that application. There are a number of problems in JavaScript (most of them originating with browser incompatibilities) that any moderately complex application will need to deal with - things like normalised event handling, DOM node selection, sane animation or drag and drop. Solve these problems once so you can get on to the interesting task of building the application. If you can find a library that solves them for you so much the better!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The big four.&lt;/strong&gt; &lt;a href=&quot;http://dojotoolkit.org/&quot;&gt;Dojo&lt;/a&gt;, &lt;a href=&quot;http://mochikit.com/&quot;&gt;MochiKit&lt;/a&gt;, &lt;a href=&quot;http://prototype.conio.net/&quot;&gt;Prototype&lt;/a&gt;/&lt;a href=&quot;http://script.aculo.us/&quot;&gt;Scriptaculous&lt;/a&gt; and the &lt;a href=&quot;http://developer.yahoo.com/yui/&quot;&gt;Yahoo! UI Library&lt;/a&gt; are the top of the pile as far as I'm concerned. They cover the bases effectively and each one offers something interesting that makes it worth studying in its own right. If you plan to evaluate some existing libraries these make an excellent starting point.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Leaky abstractions.&lt;/strong&gt; Joel Spolsky's essay &lt;a href=&quot;http://www.joelonsoftware.com/articles/LeakyAbstractions.html&quot;&gt;The Law of Leaky Abstractions&lt;/a&gt; is my favourite of all of his online articles. It's basic tenet is that abstractions that are designed to save the programmer time inevitably leak, and if they leak at a lower level of abstraction than the programmer is familiar with they prove almost impossible to debug. Paradoxically, the more time saving abstractions you are using the more you actually have to know.&lt;/p&gt;

&lt;p&gt;JavaScript is possibly the leakiest abstraction of them all, thanks to the many different browser environments it runs in. If you rely on a library to abstract away the browser bugs from you you are certain to run in to a bug that you can't fix sooner or later. Don't use libraries as crutches; if you're not prepared to figure out what the library is doing for you you'll end up in a world of pain further down the line.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Community and documentation matter.&lt;/strong&gt; As with all open-source software, it's a good idea to get a feel for the amount of community activity around a project before you commit to building on it. The big four all have active communities, which means less bugs, more support and a faster rate of improvement. Likewise, good documentation is invaluable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Libraries should play well with others.&lt;/strong&gt; Reusable code that excludes other code from being reused has severely limited long-term value. In JavaScript, that means that libraries that mess with Object.prototype or pollute global namespaces should be treated with caution. The Prototype library was a major culprit here, but thankfully has cleaned up its act (at least with regards to altering Object.prototype) in recent releases. It's all very well saying that you'll always be using code built with your core language modifications in mind, but you may well change your tune when you try to incorporate Yahoo! or Google Maps and everything breaks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Go with the grain.&lt;/strong&gt; If you take the time to learn it properly, JavaScript is a powerful and surprisingly elegant language. Good JavaScript code takes advantage of its dynamic, functional nature. Libraries that promise to take the pain out of JavaScript by &lt;a href=&quot;http://code.google.com/webtoolkit/&quot; title=&quot;The Google Web Toolkit&quot;&gt;writing the code for you&lt;/a&gt; probably aren't as smart as they seem.  Abstractions leak.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Dan Webb has &lt;a href=&quot;http://www.sitepoint.com/article/javascript-library&quot;&gt;a good comparison of the big four&lt;/a&gt; on SitePoint, although he did overlook &lt;a href=&quot;http://developer.yahoo.com/yui/animation/&quot;&gt;YUI's Animation library&lt;/a&gt; which I consider a highlight.&lt;/p&gt;

&lt;p&gt;For more accurate coverage of the @media panel itself, take a look at my co-worker Paul Hammond's &lt;a href=&quot;http://www.paulhammond.org/2006/06/atmedia2/javascript&quot;&gt;detailed notes&lt;/a&gt;.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/06/26/libraries</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2006-06-26T15:03:00-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/05/18/yahooui">
  <title>Notes from my Yahoo! UI Library talk</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;I gave my talk on the Yahoo! User Interface Library here at &lt;a href=&quot;http://xtech06.usefulinc.com/&quot;&gt;XTech&lt;/a&gt; on Tuesday. There's so much great stuff in the library that cramming it all in to 45 minutes proved impossible, so I ended up focusing on the utilities (dom, event, connection, animation and dragdrop) and providing an overview of the controls at the end.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;As with &lt;a href=&quot;http://simon.incutio.com/archive/2006/03/07/etech&quot;&gt;my JavaScript tutorial at ETech&lt;/a&gt; I made written notes before starting to compile the slides. The notes are incomplete (they abruptly end half way through the dragdrop section - at which point I decided to concentrate on putting the slides together) but should still be useful for people who haven't looked at the Library in detail:&lt;/p&gt;

&lt;p id=&quot;p-2&quot;&gt;&lt;a href=&quot;http://simon.incutio.com/slides/2006/xtech/yui-notes.html&quot;&gt;Preparatory notes for &quot;The Yahoo! User Interface Library&quot;&lt;/a&gt;&lt;/p&gt;

&lt;p id=&quot;p-3&quot;&gt;I've also uploaded &lt;a href=&quot;http://simon.incutio.com/slides/2006/xtech/yui-slides.pdf&quot;&gt;the slides&lt;/a&gt; as a 240 KB PDF.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/05/18/yahooui</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2006-05-18T13:48:22-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/05/01/speaking">
  <title>Speaking gigs</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;I've been doing a fair amount of public speaking recently, based on the principle that the only way to get good at it is to get a lot of practise. My last two talks were a session on &lt;a href=&quot;http://accu.org/index.php/conferences/2006/schedule/schedule_060420#t12a&quot;&gt;Django and Web Application Frameworks&lt;/a&gt; at the &lt;a href=&quot;http://accu.org/index.php/conferences/2006/&quot;&gt;ACCU 2006 conference&lt;/a&gt; and a talk on the &lt;a href=&quot;http://developer.yahoo.com/&quot;&gt;Yahoo! Developer Network&lt;/a&gt; for NMK's &lt;a href=&quot;http://www.nmk.co.uk/event/2006/04/27/beers-innovation-mashup&quot;&gt;Beers and Innovation series&lt;/a&gt;.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;I've got a bunch more coming up. Here's my calendar for the next few months:&lt;/p&gt;

&lt;h4&gt;&lt;a href=&quot;http://xtech06.usefulinc.com/&quot;&gt;XTech 2006&lt;/a&gt;, May 16th-19th in Amsterdam&lt;/h4&gt;

&lt;p id=&quot;p-2&quot;&gt;I'm chairing the &lt;a href=&quot;http://xtech06.usefulinc.com/content/ajax&quot;&gt;Ajax Developers' Day&lt;/a&gt;, during which I'll also be giving a talk about the &lt;a href=&quot;http://developer.yahoo.com/yui/&quot;&gt;Yahoo! UI Library&lt;/a&gt;. The line-up for the day is pretty impressive, including representatives from a number of high-profile Ajax projects and a keynote by &lt;a href=&quot;http://alex.dojotoolkit.org/&quot;&gt;Alex Russell&lt;/a&gt;. I'm also giving &lt;a href=&quot;http://xtech06.usefulinc.com/schedule/detail/140&quot;&gt;a talk on Django&lt;/a&gt; later in the conference.&lt;/p&gt;

&lt;h4&gt;&lt;a href=&quot;http://london.pm.org/ljs-200605/&quot;&gt;London JavaScript Night&lt;/a&gt;, May 25th, London&lt;/h4&gt;

&lt;p id=&quot;p-3&quot;&gt;This is &lt;q cite=&quot;http://london.pm.org/ljs-200605/&quot;&gt;a night of talks that are in someway related to the JavaScript language&lt;/q&gt;. I'm giving an overview of the most important JavaScript libraries, how they compare and the general problems that they are trying to solve. The organisers are still looking for speakers, so drop them a line if you have something to share.&lt;/p&gt;

&lt;h4&gt;&lt;a href=&quot;http://www.vivabit.com/atmedia2006/&quot;&gt;@media 2006&lt;/a&gt;, June 15th-16th, London&lt;/h4&gt;

&lt;p id=&quot;p-4&quot;&gt;I'm on &lt;a href=&quot;http://www.vivabit.com/atmedia2006/sessions/#dom&quot;&gt;a panel&lt;/a&gt; with Cameron Adams, Peter-Paul Koch, Stuart Langridge and Dan Webb talking about the benefits (and drawbacks) of JavaScript libraries.&lt;/p&gt;

&lt;p id=&quot;p-5&quot;&gt;I'm also hoping to speak at &lt;a href=&quot;http://www.lugradio.org/live/2006/index.php/Main_Page&quot;&gt;LUG Radio Live&lt;/a&gt; in July and &lt;a href=&quot;http://www.clearleft.com/dconstruct06/&quot;&gt;d.Construct 2006&lt;/a&gt; in September, topics undecided.&lt;/p&gt;

&lt;p id=&quot;p-6&quot;&gt;Finally, I'm heading to a couple of geeky social events this week: &lt;a href=&quot;http://www.pubstandards.co.uk/2006/04/25/pub-standards-7-tuesday-2nd-may-2006/&quot;&gt;Pub Standards&lt;/a&gt; on Tuesday and &lt;a href=&quot;http://www.magpiebrain.com/blog/2006/04/18/london-20-rc-5-wednesday-may-3rd/&quot;&gt;London 2.0 RC 5&lt;/a&gt; (the monthly Django/Python/Rails/Everything-else meetup) on Wednesday. Both events are fun, friendly and open to all.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/05/01/speaking</link>
  <dc:subject>DHTML and Javascript, Personal, Django</dc:subject>
  <dc:date>2006-05-01T23:23:21-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/03/07/etech">
  <title>My ETech JavaScript tutorial</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;I gave a three hour JavaScript tutorial at &lt;a href=&quot;http://conferences.oreillynet.com/et2006/&quot;&gt;ETech&lt;/a&gt; this morning, aimed at people with previous programming experience who hadn't yet dived deep in to JavaScript as a programming language. It seemed to go pretty well - some good questions were asked at various points and a few people told me afterwards that they had found it interesting.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;I didn't finish the presentation in time to get handouts made up - in fact I was adding the finishing touches 15 minutes before the session began - so I'm posting the slides here. The 111 slides (reduced to low quality JPEGs with Keynote to save on bandwidth) start here: &lt;a href=&quot;http://simon.incutio.com/slides/2006/etech/javascript/js-tutorial.001.html&quot;&gt;A (Re)-Introduction to JavaScript&lt;/a&gt;.&lt;/p&gt;

&lt;p id=&quot;p-2&quot;&gt;For the sake of completeness, I'm also releasing &lt;a href=&quot;http://simon.incutio.com/slides/2006/etech/javascript/js-reintroduction-notes.pdf&quot;&gt;the notes I made&lt;/a&gt; in preparation for the talk (PDF). These are pretty rough and don't match what I actually said very closely but they might be of interest in any case.&lt;/p&gt;

&lt;p id=&quot;p-3&quot;&gt;The photos in the presentation were all found using Flickr's awesome &lt;a href=&quot;http://www.flickr.com/creativecommons/&quot;&gt;Creative Commons search feature&lt;/a&gt;.&lt;/p&gt;

&lt;p id=&quot;p-4&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; I've converted the notes to a single HTML file with permalinks for each of the sections: &lt;a href=&quot;http://simon.incutio.com/slides/2006/etech/javascript/js-reintroduction-notes.html&quot;&gt;A (Re)-Introduction to JavaScript (HTML).&lt;/a&gt;&lt;/p&gt;

&lt;p id=&quot;p-5&quot;&gt;There's a lot of interest in the slides as a single file. The PDF is 50MB thanks to all of the images, but I'll see about getting it hosted on the ETech site. In the mean-time, I've posted higher quality copies of the slides &lt;a href=&quot;http://www.flickr.com/photos/simon/sets/72057594077197868/&quot;&gt;to Flickr&lt;/a&gt;.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/03/07/etech</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2006-03-07T05:42:23-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/02/14/ui">
  <title>Yahoo! UI JavaScript treats</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;The &lt;a href=&quot;http://developer.yahoo.net/&quot;&gt;Yahoo! Developer Network&lt;/a&gt; was updated yesterday with a veritable gold-mine of Exciting New Stuff, coinciding with the launch of the brand new &lt;a href=&quot;http://yuiblog.com/&quot;&gt;Yahoo! User Interface Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;Here are some of the highlights:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;p id=&quot;p-2&quot;&gt;Mature, extensively tested cross-browser JavaScript libraries for &lt;a href=&quot;http://developer.yahoo.net/yui/animation/index.html&quot;&gt;animation&lt;/a&gt;, &lt;a href=&quot;http://developer.yahoo.net/yui/event/index.html&quot;&gt;event handling&lt;/a&gt;, &lt;a href=&quot;http://developer.yahoo.net/yui/dom/index.html&quot;&gt;DOM wrangling&lt;/a&gt;, &lt;a href=&quot;http://developer.yahoo.net/yui/connection/index.html&quot;&gt;XMLHttpRequest&lt;/a&gt; and &lt;a href=&quot;http://developer.yahoo.net/yui/dragdrop/index.html&quot;&gt;Drag and Drop&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-3&quot;&gt;CSS-skinnable UI controls built on those libraries: &lt;a href=&quot;http://developer.yahoo.net/yui/calendar/index.html&quot;&gt;Calendar&lt;/a&gt;, &lt;a href=&quot;http://developer.yahoo.net/yui/slider/index.html&quot;&gt;Slider&lt;/a&gt; and &lt;a href=&quot;http://developer.yahoo.net/yui/treeview/index.html&quot;&gt;TreeView&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-4&quot;&gt;A library of &lt;a href=&quot;http://developer.yahoo.net/ypatterns/index.php&quot;&gt;documented design patterns&lt;/a&gt; for modern web applications.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-5&quot;&gt;A description of Yahoo!'s &lt;a href=&quot;http://developer.yahoo.net/yui/articles/gbs/gbs.html&quot;&gt;Graded Browser Support&lt;/a&gt; policy, which should be of great interest to anyone who cares about Web Standards, semantic HTML, accessibility, progressive enhancement and unobtrusive JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p id=&quot;p-6&quot;&gt;The code is all under a BSD Open Source license, which means you can use it freely in your own projects, including for commercial development.&lt;/p&gt;

&lt;p id=&quot;p-7&quot;&gt;This release represents the culmination of more than 9 months of work by an incredibly talented team. Eric Miraglia provides some &lt;a href=&quot;http://blog.360.yahoo.com/blog-JG9noGk0aa9kLMDBru_y9a2uxmo-?p=112&quot; title=&quot;Yahoo User Interface Library: Open Source Release&quot;&gt;behind-the-scenes insight&lt;/a&gt; in to the work that has gone in to the code.&lt;/p&gt;

&lt;p id=&quot;p-8&quot;&gt;I've been playing with this internally quite a bit over the past few months and I keep finding new useful bits and pieces. Here are some of my favourite details:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;p id=&quot;p-9&quot;&gt;The Event library normalises the event model across multiple browsers, including workarounds for many of the weird frustrations faced when dealing with Safari. It cleans up events when the page is unloaded, which guards against a whole swathe of memory leak problems in IE. Best of all, if you assign an event to the DOM ID of an element that has not yet been loaded, the library keeps trying to attach the event (polling) until it succeeds or the page finishes loading.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-10&quot;&gt;The CustomEvent library implements the publish-subscribe/listener pattern for you to use within your own scripts.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-11&quot;&gt;The Dom library's getStyle and setStyle methods include cross-browser support for the CSS 3 opacity property.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-12&quot;&gt;The Animation library uses a global Animation Manager object to oversee all animations on the page. This means it can adjust the frame-rate depending on how much stuff is happening - so if you tell a block to move across the screen in 1 second it will happen in one second no matter how much other stuff is going on at the same time.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-13&quot;&gt; Here's a surprisingly tricky question: when does a drag start? When the user presses down on the mouse they might be starting a click rather than a drag. The Drag and Drop library defaults to starting a drag after a user either clicks and moves 3 pixels or more, or holds the mouse down for over a second.&lt;/p&gt;&lt;/li&gt;
  &lt;li&gt;&lt;p id=&quot;p-14&quot;&gt;The Drag library also makes it easy to have elements &quot;grouped&quot; so that they can only interact with other elements in the same group - see &lt;a href=&quot;http://developer.yahoo.net/yui/dragdrop/examples/targetable.html?mode=dist&quot; title=&quot;Multiple groups, targetable affordance&quot;&gt;this demo&lt;/a&gt; for an example.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p id=&quot;p-15&quot;&gt;And finally, I couldn't resist quoting this bit of code from &lt;a href=&quot;http://developer.yahoo.net/yui/animation/examples/anim_size_plus.html&quot; title=&quot;Animation Example - Size Plus Other Attributes&quot;&gt;one of the&lt;/a&gt; Animation examples:&lt;/p&gt;

&lt;blockquote cite=&quot;http://developer.yahoo.net/yui/animation/examples/anim_size_plus.html&quot;&gt;&lt;pre&gt;&lt;code&gt;var attributes = {
   width: { to: 100 },
   height: { to: 100 },
   fontSize: { from: 100, to: 50, unit: '%' },
   opacity: { to: 0.5 }
}
var anim = new YAHOO.util.Anim('size', attributes, 1,
  YAHOO.util.Easing.easeOut);
&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p id=&quot;p-16&quot;&gt;A big thanks to the team that put this all together.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/02/14/ui</link>
  <dc:subject>DHTML and Javascript, Human Computer Interaction</dc:subject>
  <dc:date>2006-02-14T14:01:12-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2006/01/20/escape">
  <title>Escaping regular expression characters in JavaScript</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;JavaScript's support for regular expressions is generally pretty good, but there is one notable omission: an escaping mechanism for literal strings. Say for example you need to create a regular expression that removes a specific string from the end of a string. If you know the string you want to remove when you write the script this is easy:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
var newString = oldString.replace(/Remove from end$/, '');
&lt;/code&gt;&lt;/pre&gt;

&lt;p id=&quot;p-1&quot;&gt;But what if the string to be removed comes from a variable? You'll need to construct a regular expression from the variable, using the RegExp constructor function:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
var re = new RegExp(stringToRemove + '$');
var newString = oldString.replace(re, '');
&lt;/code&gt;&lt;/pre&gt;

&lt;p id=&quot;p-2&quot;&gt;But what if the string you want to remove may contain regular expression metacharacters - characters like $ or . that affect the behaviour of the expression? Languages such as Python provide functions for escaping these characters (see &lt;a href=&quot;http://docs.python.org/lib/node115.html#l2h-883&quot; title=&quot;Python re module contents&quot;&gt;re.escape&lt;/a&gt;); with JavaScript you have to write your own.&lt;/p&gt;

&lt;p id=&quot;p-3&quot;&gt;Here's mine:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
RegExp.escape = function(text) {
  if (!arguments.callee.sRE) {
    var specials = [
      '/', '.', '*', '+', '?', '|',
      '(', ')', '[', ']', '{', '}', '\\'
    ];
    arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
  }
  return text.replace(arguments.callee.sRE, '\\$1');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p id=&quot;p-4&quot;&gt;This deals with another common problem in JavaScript: compiling a regular expression once (rather than every time you use it) while keeping it local to a function. &lt;code&gt;argmuments.callee&lt;/code&gt; inside a function always refers to the function itself, and since JavaScript functions are objects you can store properties on them. In this case, the first time the function is run it compiles a regular expression and stashes it in the sRE property. On subsequent calls the pre-compiled expression can be reused.&lt;/p&gt;

&lt;p id=&quot;p-5&quot;&gt;In the above snippet I've added my function as a property of the &lt;code&gt;RegExp&lt;/code&gt; constructor. There's no pressing reason to do this other than a desire to keep generic functionality relating to regular expression handling the same place. If you rename the function it will still work as expected, since the use of &lt;code&gt;arguments.callee&lt;/code&gt; eliminates any coupling between the function definition and the rest of the code.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2006/01/20/escape</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2006-01-20T12:19:13-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/12/16/json">
  <title>JSON and Yahoo!'s JavaScript APIs</title>
  <description>&lt;p&gt;I had the pleasure yesterday of seeing Douglas Crockford speak about &lt;a href=&quot;http://www.crockford.com/JSON/index.html&quot;&gt;JSON&lt;/a&gt;, the ultra-simple data interchange format he has been promoting as an alternative to XML. JSON is a subset of JavaScript, based around that language's array, string and object literal syntax.&lt;/p&gt;

&lt;p&gt;As of today, JSON is supported as an &lt;a href=&quot;http://developer.yahoo.net/common/json.html&quot;&gt;alternative output format&lt;/a&gt; for nearly all of Yahoo!'s Web Service APIs. This is a &lt;em&gt;Really Big Deal&lt;/em&gt;, because it makes Yahoo!'s APIs available to JavaScript running anywhere on the web without any of the &lt;a href=&quot;http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html&quot;&gt;normal problems&lt;/a&gt; caused by XMLHttpRequest's cross domain security policy.&lt;/p&gt;

&lt;p&gt;Like JSON itself, the workaround is simple. You can append two arguments to a Yahoo! REST Web Service call:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
&amp;amp;output=json&amp;amp;callback=myFunction
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The page returned by the service will look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
myFunction({ JSON data here });
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You just need to define &lt;code&gt;myFunction&lt;/code&gt; in your code and it will be called when the script is loaded. To make cross-domain requests, just dynamically create your script tags using the DOM:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '...' + '&amp;amp;output=json&amp;amp;callback=myFunction';
document.getElementsByTagName('head')[0].appendChild(script);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In long running apps you'll want to work out some kind of cleanup system to remove script tags from the DOM once they have been executed. More on this technique &lt;a href=&quot;http://www.theurer.cc/blog/2005/12/15/web-services-json-dump-your-proxy/&quot; title=&quot;Web Services + JSON = Dump Your Proxy&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It should be noted that &lt;a href=&quot;http://del.icio.us/&quot;&gt;del.icio.us&lt;/a&gt; has had &lt;a href=&quot;http://del.icio.us/help/json&quot;&gt;APIs like this&lt;/a&gt; for a while.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/12/16/json</link>
  <dc:subject>Web Services, DHTML and Javascript</dc:subject>
  <dc:date>2005-12-16T00:10:57-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/10/05/canvas">
  <title>Canvas demos</title>
  <description>&lt;p&gt;Jesse Andrews (of &lt;a href=&quot;http://bookburro.org/&quot;&gt;Book Burro&lt;/a&gt; and &lt;a href=&quot;http://userscripts.org/&quot;&gt;userscripts.org&lt;/a&gt; fame) has built some &lt;a href=&quot;http://overstimulate.com/projects/canvas/&quot;&gt;awesome canvas demos&lt;/a&gt; for users of Safari or Firefox 1.5. He has a bar chart and some animated rectangles, but the real gem is the live chart which polls a server using XMLHttpRequest and updates a line graph with live data. He also has some fun mathematical experiments: a cellular automata generator and a neat exploration of &lt;a href=&quot;http://en.wikipedia.org/wiki/Lindenmayer_System&quot;&gt;Lindenmayer systems&lt;/a&gt; (both &lt;a href=&quot;http://overstimulate.com/projects/canvas/lindenmayer.html&quot; title=&quot;Canvas Lindenmayer Systems&quot;&gt;static&lt;/a&gt; and &lt;a href=&quot;Interactive Canvas Lindenmayer Systems&quot;&gt;interactive&lt;/a&gt;). Read more &lt;a href=&quot;http://overstimulate.com/articles/2005/10/04/canvas-examples&quot; title=&quot;overstimulate: Canvas examples&quot;&gt;on his blog&lt;/a&gt;.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/10/05/canvas</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-10-05T16:43:36-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/09/17/monkeyfun">
  <title>More fun with the monkey</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;Cory Doctorow points to &lt;a href=&quot;http://memory.loc.gov/ammem/fsachtml/fsacsubjindex1.html&quot;&gt;America from the Great Depression to World War II: Color Photographs from the FSA-OWI, 1939-1945&lt;/a&gt;, with the &lt;a href=&quot;http://www.boingboing.net/2005/09/16/color_photos_of_the_.html&quot; title=&quot;Color photos of the US 1939-1945&quot;&gt;following observation&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote cite=&quot;http://www.boingboing.net/2005/09/16/color_photos_of_the_.html&quot;&gt;&lt;p id=&quot;p-1&quot;&gt;Unfortunately, the organizational back-end for this is so primitive (especially in comparison with modern image-sharing and organizing sites like &lt;a href=&quot;http://flickr.com/&quot;&gt;Flickr&lt;/a&gt;) that it, too, seems to hail from 1939-1945, making the site a real pain to navigate and use.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p id=&quot;p-2&quot;&gt;Thanks to &lt;a href=&quot;http://greasemonkey.mozdev.org/&quot;&gt;Greasemonkey&lt;/a&gt;, great content spoiled by poor navigation is a solvable problem.&lt;/p&gt;

&lt;p id=&quot;p-3&quot;&gt;&lt;a href=&quot;http://simon.incutio.com/code/greasemonkey/americanmemoryfixer.user.js&quot;&gt;americanmemoryfixer.user.js&lt;/a&gt; includes the following improvements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Changes the colour scheme to black-on-white, and the typeface to Verdana.&lt;/li&gt;
  &lt;li&gt;Removes all table borders.&lt;/li&gt;
  &lt;li&gt;Adds headings to some pages, and fixes various title tags.&lt;/li&gt;
  &lt;li&gt;Sets the default gallery view to be a set of thumbnails, rather than a list of names.&lt;/li&gt;
  &lt;li&gt;Displays a large image (as opposed to a thumbnail) when you view a photograph.&lt;/li&gt;
&lt;/ul&gt;

&lt;p id=&quot;p-4&quot;&gt;The scariest hack in the script is the way in which subject page titles are passed around. In the current site, if you visit a category page (such as &lt;a href=&quot;http://memory.loc.gov/cgi-bin/query/r?ammem/fsaall:@FILREQ(@field(SUBJ+@band(Sharecroppers+))+@FIELD(COLLID+fsac))&quot;&gt;Sharecroppers&lt;/a&gt;) the title of the category is not displayed on the page - even though it has been passed as a parameter in the URL. If you click a link (say to the Galley thumbnail page) the information in the URL is lost as well.&lt;/p&gt;

&lt;p id=&quot;p-5&quot;&gt;My solution was to extract the subject from the URL on that first page, then rewrite the other links to include an additional &quot;&amp;amp;subject=Sharecroppers&quot; parameter. This new parameter is ignored by the CGI scripts that power the site, but my Greasemonkey script watches out for it on subsequent pages and uses it to  display a title (and further propagate it to other links on the page). It's not a very robust solution, but it's good enough.&lt;/p&gt;

&lt;p id=&quot;p-6&quot;&gt;There's plenty of scope for further improvement - if you want to use my script as a starting point, please feel free.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/09/17/monkeyfun</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-09-17T19:44:56-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/09/11/firefox15">
  <title>Firefox 1.5 developer highlights</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;&lt;a href=&quot;http://www.mozilla.org/products/firefox/releases/1.5beta1.html&quot;&gt;Firefox 1.5 Beta 1 is out&lt;/a&gt;, and is the most exciting browser release in a very long time. It comes with the Gecko 1.8 rendering engine, which includes a ton of interesting new features. New in this version (unless you've been tinkering with the Deer Park series):&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;SVG&lt;/li&gt;
 &lt;li&gt;Canvas&lt;/li&gt;
 &lt;li&gt;CSS3 Columns&lt;/li&gt;
 &lt;li&gt;JavaScript 1.6&lt;/li&gt;
&lt;/ul&gt;

&lt;p id=&quot;p-1&quot;&gt;Let's take a look at these in turn.&lt;/p&gt;

&lt;h4&gt;SVG&lt;/h4&gt;

&lt;p id=&quot;p-2&quot;&gt;The &lt;a href=&quot;http://www.mozilla.org/projects/svg/&quot;&gt;Mozilla SVG project&lt;/a&gt; has been quietly chugging along for years now, but until quite recently you needed to download an entirely separate build of Mozilla to try it out. Firefox 1.5 is the first Firefox release to include it and opens up a whole new world of vector graphics to web developers. The &lt;a href=&quot;http://www.croczilla.com/svg/samples/&quot;&gt;Croczilla Examples page&lt;/a&gt; is a great place to start - be sure to try the interactive demos near the bottom. There's more about Mozilla's SVG support &lt;a href=&quot;http://developer.mozilla.org/en/docs/SVG&quot; title=&quot;SVG on Devmo&quot;&gt;on the Mozilla Developer Centre&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Canvas&lt;/h4&gt;

&lt;p id=&quot;p-3&quot;&gt;The &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element introduces a modern 2D drawing API to client-side development, with the promise of a 3D API in the future. It was invented by Apple for use in Dashboard widgets, then written up as &lt;a href=&quot;http://whatwg.org/specs/web-apps/current-work/#dynamic&quot; title=&quot;5.1. Dynamic graphics: The bitmap canvas&quot;&gt;a specification&lt;/a&gt; by the WHATWG to facilitate compatible implementations in other browsers. &lt;/p&gt;

&lt;p id=&quot;p-4&quot;&gt;The potential for innovation with &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; is enormous. Demos are pretty thin on the ground at the moment, but this &lt;a href=&quot;http://ponderer.org/download/canvas_demo/&quot;&gt;interactive demo&lt;/a&gt; by Darin Fisher hints at the things to come. The &lt;a href=&quot;http://mozilla.doslash.org/stuff/canvas/shell.html&quot;&gt;Canvas shell&lt;/a&gt; is handy for playing with the API. Devmo has the beginnings of a great &lt;a href=&quot;http://developer.mozilla.org/en/docs/Canvas_tutorial&quot;&gt;Canvas tutorial&lt;/a&gt;. &lt;a href=&quot;http://undefined.org/js/canvas0000.html&quot;&gt;This thing&lt;/a&gt; (originally a Safari 1.3 demo) is pretty too.&lt;/p&gt;

&lt;p id=&quot;p-5&quot;&gt;The ability for Firefox extensions to &lt;a href=&quot;http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html&quot;&gt;render web pages to images&lt;/a&gt; using &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; should lead to some very cool new extensions in the future.&lt;/p&gt;

&lt;h4&gt;CSS3 Columns&lt;/h4&gt;

&lt;p id=&quot;p-6&quot;&gt;The ability to create auto-flowing columns (famously achieved on &lt;a href=&quot;http://www.iht.com/&quot;&gt;IHT.com&lt;/a&gt; using terrifyingly hairy JavaScript) has long been desired for the web - among other things it's a neat way of keeping line widths comfortably readable. The &lt;a href=&quot;http://www.w3.org/TR/2001/WD-css3-multicol-20010118/&quot;&gt;CSS3 Multi-column layout module&lt;/a&gt; enables this ability, and Gecko 1.8 implements parts of it in the form of the &lt;code&gt;-moz-column-count&lt;/code&gt;, &lt;code&gt;-moz-column-width&lt;/code&gt; and &lt;code&gt;-moz-column-gap&lt;/code&gt; properties - the &lt;code&gt;-moz-&lt;/code&gt; prefix is &lt;a href=&quot;http://www.w3.org/TR/CSS21/syndata.html#q4&quot; title=&quot;CSS 2.1: Syntax and basic data types&quot;&gt;W3C approved syntax&lt;/a&gt; for vendor-specific CSS extensions. You can see columns in action on &lt;a href=&quot;http://weblogs.mozillazine.org/roc/archives/2005/03/gecko_18_for_we.html&quot; title=&quot;Gecko 1.8 For Web Developers: Columns&quot;&gt;Robert O'Callahan's blog&lt;/a&gt; (Robert implemented column support in Gecko). Devmo's &lt;a href=&quot;http://developer.mozilla.org/en/docs/CSS3_Columns&quot;&gt;column documentation&lt;/a&gt; has further details.&lt;/p&gt;

&lt;h4&gt;JavaScript 1.6&lt;/h4&gt;

&lt;p id=&quot;p-7&quot;&gt;According to &lt;a href=&quot;http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6&quot;&gt;New in JavaScript 1.6&lt;/a&gt;, the new features are E4X support, Array extras and &quot;Array and String generics&quot;. I can't find anything detailing what the latter means, but the first two are pretty interesting. E4X (aka &lt;a href=&quot;http://www.ecma-international.org/publications/standards/Ecma-357.htm&quot; title=&quot;Standard ECMA-357&quot;&gt;ECMAScript for XML&lt;/a&gt;) is a relatively new specification which promotes XML to a native data type. It lets you do things like this:&lt;/p&gt;


&lt;blockquote cite=&quot;http://www.mozdev.org/pipermail/greasemonkey/2005-September/005639.html&quot;&gt;&lt;pre&gt;&lt;code&gt;
var x = &amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;baz&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;;
alert(x.bar);
x.monkey = &quot;good&quot;;
alert(x.toXMLString());

for each (var child in x) {
  alert(x.toXMLString());
}&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p id=&quot;p-8&quot;&gt;(Example excerpted from &lt;a href=&quot;http://www.mozdev.org/pipermail/greasemonkey/2005-September/005639.html&quot; title=&quot;[Greasemonkey] e4x (say horray)&quot;&gt;Aaron's post&lt;/a&gt; to the Greasemonkey mailing list.)&lt;/p&gt;

&lt;p id=&quot;p-9&quot;&gt;It isn't available within script tags by default: you have to explicitly turn it on with &lt;code&gt;&amp;lt;script type=&quot;text/javascript;e4x=1&quot;&amp;gt;&lt;/code&gt;, presumably to preserve backwards compatibility with existing pages.&lt;/p&gt;

&lt;p id=&quot;p-10&quot;&gt;Array extras consist of some new methods on the &lt;code&gt;Array&lt;/code&gt; class, the most interesting of which are &lt;code&gt;every()&lt;/code&gt;, &lt;code&gt;forEach()&lt;/code&gt;, &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;filter()&lt;/code&gt; and &lt;code&gt;some()&lt;/code&gt;. Each of these takes a function reference (i.e. a callback) as an argument and applies it to each item in the array in some manner. Fans of functional programming techniques will welcome these, and they can easily be enabled in older browsers by conditionally modifying &lt;code&gt;Array.prototype&lt;/code&gt;. WebReference.com has &lt;a href=&quot;http://www.webreference.com/programming/javascript/ncz/column4/index.html&quot; title=&quot;Mozilla's New Array Methods&quot;&gt;a tutorial&lt;/a&gt; covering the new array methods.&lt;/p&gt;

&lt;p id=&quot;p-11&quot;&gt;If anyone knows what &quot;Array and String generics&quot; are, please leave a comment!&lt;/p&gt;

&lt;p id=&quot;p-12&quot;&gt;The above are just the highlights of Firefox 1.5 from a web developer's perspective. The improvements for regular users are also notable, including re-orderable tabs, caching of browser state for lightning-fast back and forward and lots of cosmetic (and performance) improvements for the Mac version. An &lt;a href=&quot;http://www.squarefree.com/burningedge/releases/1.5b1.html&quot; title=&quot;What's new in Firefox 1.5 Beta 1&quot;&gt;unofficial changelog&lt;/a&gt; is available courtesy of the Burning Edge.&lt;/p&gt;

&lt;p id=&quot;p-13&quot;&gt;Exciting times indeed.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/09/11/firefox15</link>
  <dc:subject>Mozilla, DHTML and Javascript</dc:subject>
  <dc:date>2005-09-11T13:46:19-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/07/20/vulnerability">
  <title>Understanding the Greasemonkey vulnerability</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;If you have any version of Greasemonkey installed prior to 0.3.5, which was released a few hours ago, or if you are running any of the 0.4 alphas, you need to go and upgrade &lt;a href=&quot;http://greasemonkey.mozdev.org/&quot;&gt;right now&lt;/a&gt;. All versions of Greasemonkey aside from 0.3.5 contain a &lt;a href=&quot;http://mozdev.org/pipermail/greasemonkey/2005-July/004022.html&quot; title=&quot;Mark Pilgrim's announcement of the vulnerability&quot;&gt;nasty security hole&lt;/a&gt;, which could enable malicious web sites to read any file from your hard drive without you knowing.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;Unfortunately, 0.3.5 disables all of the &lt;a href=&quot;http://diveintogreasemonkey.org/api/&quot;&gt;GM_ API functions&lt;/a&gt;, without which many of the more interesting user scripts out there simple won't work. This is a temporary measure - the &lt;code&gt;GM_&lt;/code&gt; functions should return in a later release, once the security problem with them has been resolved.&lt;/p&gt;

&lt;p id=&quot;p-2&quot;&gt;I'm going to explain how the vulnerability works, because it illustrates a number of interesting concepts in both web application security and JavaScript.&lt;/p&gt;

&lt;h4&gt;Same-origin policy&lt;/h4&gt;

&lt;p id=&quot;p-3&quot;&gt;JavaScript has always enforced a &lt;em&gt;same-origin policy&lt;/em&gt; for scripts loaded over the internet. This originally applied to scripting between frames (and iframes): a script loaded from a certain domain is only allowed to access the DOM of other pages loaded from that same domain. The same restriction has been extended to &lt;code&gt;XMLHttpRequest&lt;/code&gt; - you are only allowed to make an &lt;code&gt;XMLHttpRequest&lt;/code&gt; call back to the domain from which the script was originally loaded.&lt;/p&gt;

&lt;p id=&quot;p-4&quot;&gt;This policy exists to prevent cross-domain attacks. Say for example you work for a company with an intranet hidden behind the firewall, full of interesting proprietary information. Without the same-origin policy, malicious sites that you visit on the public internet would be able to read information from your intranet, using your browser as the middle-man.&lt;/p&gt;

&lt;h4&gt;GM_xmlhttpRequest&lt;/h4&gt;

&lt;p id=&quot;p-5&quot;&gt;The &lt;code&gt;GM_xmlhttpRequest&lt;/code&gt; API function does not have this restriction - it can load data from any domain. This enables a whole host of interesting user scripts - the most famous of which is probably &lt;a href=&quot;http://bookburro.org/&quot;&gt;Book Burro&lt;/a&gt;, which shows comparison prices from different online stores for the item you are currently looking at on Amazon, Barnes and Noble and more.&lt;/p&gt;

&lt;p id=&quot;p-6&quot;&gt;Malicious user scripts could use this feature to steal information from your private intranet, but malicious user scripts could also do all manner of other nasty things - stealing your Hotmail password for example. This is why you should never install a user script from an untrusted source without first reviewing the code.&lt;/p&gt;

&lt;h4&gt;Restricting API functions to user scripts only&lt;/h4&gt;

&lt;p id=&quot;p-7&quot;&gt;To keep things safe then, it is essential that the &lt;code&gt;GM_&lt;/code&gt; family of API functions can only ever be used by user scripts, not by code running on pages that you have visited. By installing a user script you have declared it trustworthy - but visiting a web page does not carry that contract.&lt;/p&gt;

&lt;p id=&quot;p-8&quot;&gt;The way the flawed versions of Greasemonkey do that now is simple: the &lt;code&gt;GM_&lt;/code&gt; functions are added to the JavaScript global object (which is the window object), the user scripts for the page are &quot;injected&quot; using dynamically created &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; elements, they run, then the &lt;code&gt;GM_&lt;/code&gt; functions are removed from the global object to prevent scripts on the page from accessing them. This works because Greasemonkey injection and execution happens just before the onload event is fired - which is when most well behaved scripts kick in.&lt;/p&gt;

&lt;h4&gt;Object.watch()&lt;/h4&gt;

&lt;p id=&quot;p-9&quot;&gt;Here's the clever part: JavaScript 1.5 defines a method of the Object class (which is inherited by all other JavaScript objects) called &lt;a href=&quot;http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Object:watch&quot;&gt;watch&lt;/a&gt;. Watch is extremely powerful: it lets you register some code to be executed when a property on some other object is assigned. This is the key to the Greasemonkey vulnerability - by watching the window object for the point at which Greasemonkey adds the API functions, a malicious script can use those functions at the moment they are attached.&lt;/p&gt;

&lt;h4&gt;The file:// protocol&lt;/h4&gt;

&lt;p id=&quot;p-10&quot;&gt;Here's the final piece of the puzzle: the &lt;code&gt;file://&lt;/code&gt; protocol in Firefox allows you to view files and directory listings in your browser. Unfortunately, it also allows the &lt;code&gt;GM_xmlhttpRequest&lt;/code&gt; function to do the same. It's not at all hard for a malicious script to use the function to load in files at a known location - or even load in directory listings (as HTML), parse them and use them to find all kinds of things scattered around your hard drive.&lt;/p&gt;

&lt;h4&gt;Solving the problem&lt;/h4&gt;

&lt;p id=&quot;p-11&quot;&gt;The principle problem then is the requirement for &quot;safe&quot; Greasemonkey API functions - that is, functions that can be used by the user scripts but &lt;em&gt;not&lt;/em&gt; by code running on a website. Aaron is looking in to this right now - it looks like the solution will require a minor change to be made to many existing scripts, but the trade-off in terms of security is more than worth it. The &lt;code&gt;GM_xmlhttpRequest&lt;/code&gt; function will also be modified to disallow &lt;code&gt;file://&lt;/code&gt; URLs.&lt;/p&gt;

&lt;p id=&quot;p-12&quot;&gt;Until then, 0.3.5 is the only safe version of Greasemonkey.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/07/20/vulnerability</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-07-20T03:09:19-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/06/06/wikipedia">
  <title>Tweaking Wikipedia</title>
  <description>&lt;p id=&quot;p-0&quot;&gt;Does anyone know why &lt;a href=&quot;http://en.wikipedia.org/&quot;&gt;Wikipedia&lt;/a&gt; displays a redirected page at the same &lt;acronym title=&quot;Universal Republic of Love&quot;&gt;URL&lt;/acronym&gt; rather than using a proper &lt;acronym title=&quot;HyperText Transfer Protocol&quot;&gt;HTTP&lt;/acronym&gt; redirect? Case in point: &lt;a href=&quot;http://en.wikipedia.org/wiki/Topics_in_human-computer_interaction&quot;&gt;Topics in human-computer interaction&lt;/a&gt; actually displays the content from &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_human-computer_interaction_topics&quot;&gt;List of human-computer interaction topics&lt;/a&gt; (that's my next exam topic) - the same content appears at two different &lt;acronym title=&quot;Universal Republic of Love&quot;&gt;URL&lt;/acronym&gt;s. Yuck. Here's a Greasemonkey script to fix it: &lt;a href=&quot;http://simon.incutio.com/code/greasemonkey/wikipedia-redirect.user.js&quot;&gt;wikipedia-redirect.user.js&lt;/a&gt;.&lt;/p&gt;

&lt;p id=&quot;p-1&quot;&gt;While I'm at it, Wikipedia's search function is painfully slow. Here's another user script which changes their search button to search the site using Google instead. It also swaps the positions of the &quot;Search&quot; and &quot;Go&quot; buttons, and makes &quot;Search&quot; the default action for the form: &lt;a href=&quot;http://simon.incutio.com/code/greasemonkey/wikipedia-googlesearch.user.js&quot;&gt;wikipedia-googlesearch.user.js&lt;/a&gt;.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/06/06/wikipedia</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-06-06T18:13:44-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/06/03/book">
  <title>Stuart's book</title>
  <description>I meant to mention this earlier, but Stuart's book, &lt;a href=&quot;http://www.sitepoint.com/books/dhtml1/&quot;&gt;DHTML Utopia: 
Modern Web Design Using JavaScript &amp;amp; DOM&lt;/a&gt;, has been published.

I worked as a technical editor on the book, and I'm proud to have been associated with it. Don't worry about the hairy title (apparently you have to have DHTML in it or bookshops won't know where to put it / people won't know what it's about), the inside is pure gold.

In their usual style, SitePoint have posted &lt;a href=&quot;http://www.sitepoint.com/article/dhtml-utopia-modern-web-design&quot;&gt;the first four chapters online&lt;/a&gt; for your perusal so you don't have to take my word for it, you can try it out for yourself.</description>
  <link>http://simon.incutio.com/archive/2005/06/03/book</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-06-03T13:44:02-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>
<item rdf:about="http://simon.incutio.com/archive/2005/05/24/fixing">
  <title>Fixing web applications with Greasemonkey</title>
  <description>&lt;p&gt;In &lt;a href=&quot;http://simon.incutio.com/archive/2005/04/14/fud&quot;&gt;Greasemonkey FUD&lt;/a&gt;, I highlighted the importance of Greasemonkey as a tool for fixing interface problems in &quot;enterprise&quot; web applications. DJ Adams has &lt;a href=&quot;https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1669&quot;&gt;done exactly that&lt;/a&gt; for OSS Notes, part of the SAP service portal. His &lt;a href=&quot;http://www.pipetree.com/~dj/2005/05/OssNoteFix/ossnotefix.user.js&quot; title=&quot;ossnotefix.user.js&quot;&gt;user script&lt;/a&gt; ditches the frames in the interface, makes the page title more useful and adds hyperlinks to other note references on the page - significantly improving the user experience in less than 40 lines of code. The improvements are clearly explained in the accompanying &lt;a href=&quot;http://www.pipetree.com/~dj/2005/05/OssNoteFix/screencast.html&quot;&gt;screencast&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Spotted &lt;a href=&quot;http://www.mozdev.org/pipermail/greasemonkey/2005-May/002393.html&quot; title=&quot;[Greasemonkey] GM script for SAP&quot;&gt;via Jeremy&lt;/a&gt; on the Greasemonkey mailing list.&lt;/p&gt;</description>
  <link>http://simon.incutio.com/archive/2005/05/24/fixing</link>
  <dc:subject>DHTML and Javascript</dc:subject>
  <dc:date>2005-05-24T01:59:40-00:00</dc:date>
  <dc:creator>Simon Willison</dc:creator>
</item>

</rdf:RDF>