Using AMD loaders to write and manage modular javascript

Recently, I gave a short presentation about AMD (Asynchronous Module Definition) at the Boston JavaScript Meetup Group. Here are the slides:

http://unscriptable.com/code/Using-AMD-loaders/

There wasn’t enough time to talk about all of the AMD loaders in existence, and certainly not enough time to dig into the many use cases and nuances of AMD-formatted modules. However, I hope I was able to help improve awareness of AMD and javascript modules in general.

Enjoy!

[Update 2011-04-27] If you’re wondering what happened to the “manage” part of the title’s “write and manage”… it’s coming in a future presentation. 🙂

curl.js – yet another AMD loader [updated]

Over the past several weeks, I’ve been writing an AMD-compatible javascript loader called curl.js. AMD stands for Asynchronous Module Definition and is a CommonJS proposed standard for writing javascript modules. The module format closely follows the proposed migration path set out by ECMA’s proposed ES-Harmony javascript modules.

curl stands for Cujo Resource Loader since it’s an integral part of the re-engineering of cujo.js.

An AMD-compatible javascript loader is (surprise, surprise) an asynchronous javascript loader that is savvy about AMD-formatted javascript modules.

[update]
Version 0.3.2 is out! fork it!

Continue reading

cujo.js — OOJS, OOCSS, and OOHTML — Part 1 (OOCSS for Engineers)

One of the coolest concepts in cujo.js is the introduction of Object-Oriented CSS into the Views and Widgets. I’ve seen several engineer’s eyes glaze over when I mention OOCSS, but don’t dismiss it as just a rehashed retelling of how to structure your CSS. OOCSS is a very powerful and efficient tool, especially when used in conjunction with Object-Oriented JavaScript and inheritable HTML templates.

I’d love to dive right in and show you how it all works in cujo.js, but you’ve got to have a firm understanding of OOCSS for any of it to make sense. Let’s get started…

Continue reading

Bizarro dojo with a slice of cujo.js [updated]

Here is the slideshow from my presentation at the Bocoup Loft on August 15th. For some reason, slideshare barfed on it even after I removed all of the video and audio. Srsly, I tried five different variations.
dojo is bizarro jQuery (bocoup)
This presentation is in the QuickTime Presentation format. You must use the space bar or arrow keys to navigate. (I seem to have to click and hit the arrow keys about a dozen times before the presentation starts.)

[update]
I finally got slideshare to accept the slides! Here’s the sideshow.

Firefox’s proposed Resource Packages spec blows!

It’s no secret that one of the keys to a decent user experience is a responsive (fast) user interface. And the most critical component to a fast web app is minimizing the HTTP requests. So it’s no mystery that people are working on ways to solve this problem.

Firefox, of course, is one of the leaders in this area. Their proposal started out fine. Here’s a sample of what it would look like (if you didn’t read the article):

<link rel="resource-package" 
      type="application/zip" 
      href="/static/site-resources.zip"
      content="javascript/jquery.js;
               css/reset.css;
               css/grid.css;
               css/main.css;
               images/save.png;
               images/info.png" />

You specify that the file, /static/site-resources.zip”, contains the listed resources. JavaScript, CSS, and images. (I imagine SWFs and videos would also be options.)

But for some reason, this concise, nearly-valid implementation was trashed in favor of a terse, unfamiliar, and nearly unusable alternative. Here’s what the spec looks like now:

<html packages='[pkg1.zip img1.png script.js styles/style.css]
                [static/pkg2.zip]'>
</html>

In this bastardization, the packages are specified as an attribute on the document element (<html> tag). Package definitions in the packages attribute are delimited by square brackets, and the resources within them are delimited by spaces.

WTF? Not only is this ugly and non-standard, but it also has some serious drawbacks. Here’s why:

Continue reading