Hi guys,
I just did a little bit of work to remove prototype/scriptaculous from
Lovd By Less and replace it with jQuery/jQuery UI. jQuery is much
lighter than Prototype and already used in Lovd By Less. Following
these instructions will also greatly reduce the file size of the
javascript includes on your Lovd By Less install.
1. Install jRails, a drop-in jQuery replacement for Rails from
http://ennerchi.com/projects/jrails. jRails essentially re-routes
rails helpers to use jQuery instead of prototype.
On windows you would run the following in your Lovd By Less root
folder to install jRails:
ruby script\plugin install
http://ennerchi.googlecode.com/svn/trunk/plugins/jrails
2. Modify the headers in your app\views\layouts\application.html.erb
file and app\views\layouts\plain.html.erb file to remove prototype/
scriptaculous and reference jQuery. I'm also using the google ajax API
to serve jQuery which reduces server load and allows for the
posibility of your user already having the library cached.
Your headers in the application.html.erb and plain.html.erb should
look like this:
<script src="
http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.2.6");
google.load("jqueryui", "1.5.2");
</script>
<%= javascript_include_tag 'jrails', 'application', 'thickbox',
'truncator', :cache=>true %>
3. Modify your public\javascripts\application.js file and add the
following at the top:
// jQuery definition
jQuery.noConflict();
jq = jQuery;
$ = jQuery;
$$ = jQuery;
4. That's it, there's no step 4.
I'm new to Lovd by Less, and clicking around so far I haven't noticed
any issues with jRails. All of the effects seem to work. Long term it
would be great to re-write the RJS helpers as stand-alone javascipt,
but for now, this solution seems to work.
- Boris
http://www.borism.net