Opinionated Programmer - Jo Liss's musings on enlightened software development.

Announcing the jquery-ui-rails Gem: jQuery UI for the Asset Pipeline

Have you ever headed to the jQuery UI download page, selected some components, downloaded a custom jQuery UI package, and dumped the files in your Rails app? Then you probably felt as undignified as I did. This is not how we should have to configure our libraries.

The only alternative right now is the jquery-rails gem, which (in addition to packaging jQuery) is nice enough to ship a jquery-ui.js asset file for your convenience. However, this gives you all of jQuery UI’s components (an extra 51KB gzipped) when you might need only one or two, and it also does not give you the CSS and image files.

To put an end to this situation, I wrote up the jquery-ui-rails gem, which packages all the JavaScript, stylesheet and image files for the Rails 3.1+ asset pipeline.

It comes with individual jQuery UI modules, and it resolves dependencies between the jQuery UI modules through the asset pipeline, so you can require the component(s) you need and things will just work.

Also, the image references in the CSS files now point at images in the asset pipeline. No more dumping PNGs in your public folder.

If you are using jQuery UI in your app right now, please give it a spin, and let me know if it works for you!

Link: https://github.com/joliss/jquery-ui-rails


P.S. Right now it only bundles the default theme (“Smoothness” I think), but once it is possible to regenerate the theme files, it should be easy to ship all the themes in the ThemeRoller gallery.

P.P.S. I haven’t tested it, but I see that CodeOfficer has made a jquery-ui-rails-helpers gem (and perhaps there are more helper gems that I don’t know about). See also jquery ui - Modifying Rails helpers to add HTML classes on Stack Overflow. I’m not looking to add helpers to the jquery-ui-rails gem, since I think it’s best to do one thing well, but if you have used helpers for jQuery UI (or written your own), please share your experiences so other people can benefit.