I recently watched DHHs presentation at RailsConf09 (http://
railsconf.blip.tv/file/2081411/). I think the "unobstrusive"
Javascript stuff (like replacing onClick="..." by data-remote=true or
similar) is very interesting.

I'm using these HTML5 data-attributes already in some of my projects
for storing additional information that are handled by javascript
functions etc.

I was curious about how this would be implemented in Rails3, but
didn't find any changes regarding this in the rails3/master-branch.
My concern with this is just about performance. So I've tried to set
up a quick performance test (using jQuery in Firefox 3).

The test may be not very representative, but I guess that the results
will not differ very much in other browsers. If you've got 5.000 HTML
elements like this

<a href="http//something.com/action/url" data-remote=true

 jQuery needs about 240ms to find all links with the data-remote=true
attribute (Syntax: $('a[data-remote=true]').each(...)).

Looking for a-tags by class jQuery only needs 50ms to find all links
( $('a.remote-link')....).

So... my suggestion is just to use classes (like "_rails_remote_link")
for finding remote forms, links etc. I know that it is unlikely to
have 5.000 links on a single page, but if you could use classes
instead of data-attributes with a performance gain of about 400%, it's
worth to think about that?


You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to