Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Nick Plante

Dr. Dobb's Bloggers

Sammy - A jQuery Web Framework

May 19, 2009

jQuery has been my JavaScript library of choice for quite some time. It's definitely one of the easiest ways to abstract away the difficulties of working with lower-level browser-dependant JavaScript when building web-based applications. However, jQuery has its limitations; it isn't really intended to stand in for a framework for building larger interaction-heavy web apps. It simply doesn't dictate how you should structure your applications or deal with higher-level concepts such as request routing.

If you're a jQuery fan and you're looking for a way to help organize development of a more robust JavaScript-heavy application (in the vein of perhaps GMail or Apple's MobileMe), you might want to take a look at Sammy, a new lightweight JavaScript framework, created by developer Aaron Quint as a layer to sit on top of jQuery.

Quint was inspired by Ruby's Sinatra framework and realized that its simple inline route action syntax could be a good fit for structuring single-page JavaScript applications. Utilizing the URL hash with Sammy's "routes", you can create one-page apps that still respond to the back button in your browser, much like GMail does. Sammy's syntax for handling this is very simple and natural (especially if you've done some Sinatra work before), and demonstrated very succintly in Quint's introductory screencast.

Sammy also makes post action handling simple, gives you access to parameters, JS event binding and triggering, partial template loading, and many other features that you might be likely to find in a robust backend development framework like Ruby on Rails or CakePHP. But Sammy also plays nicely with other frameworks like this; in fact, one of the example applications bundled with the source code demonstrates interacting with a backend Sinatra / CloudKit application.

Best of all, Sammy is well-documented and comes with a number of examples such as the one noted above, which makes it easy to learn and experiment with. So what's next? Think about pairing Sammy up with RESTful data stores like CouchDB, and bypassing the server side framework altogether. Hmmm, possibilities...

More information is available at Quint's blog and the GitHub project page. You may also want to check out the project mailing list.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.