Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Escape_utils – Fast HTML and JavaScript escaping routines for Ruby

By Peter Cooper / June 9, 2010

Being as though we’re all html escaping everything these days, why not make it faster?

At the moment escape_utils supports escaping and unescaping of HTML, and Javascript but I wanna add URL encoding soon. It has monkey-patches for Rack::Utils, CGI, ERB::Util and Haml and ActionView so you can drop this in and have your app start escaping fast as balls in no time

Brian Lopez

I don't know how fast Brian's balls are, but I could escape the jQuery source code (about 164KB) about 1000 times per second on my iMac and that seems pretty fast. It was also very easy to install on OS X (everything is done with a gem install escape_utils).

Brian claims his C-backed library is 10-20x faster than existing Ruby-based escaping techniques for HTML and 16-30x faster for JavaScript.

Other Posts to Enjoy

Twitter Mentions