My question is about thinking through Rails app.
I have a rich ajax-application which uses google maps api, jquery, jquery ui and a lot of jquery plugins such as history, browser, hotkeys and scrollto.
Now it has a PHP backend, but I want to rewrite it in the Rails on Rails.
Would it be normal to remove all of the Rails javascripts (e.g. javascript_include_tag) from the code and use only my?
You could do it if you felt like it. The main (only?) reason to use
javascript_include_tagis to make sure that when JS scripts hosted on your server change, your users’ browsers download the new script instead of using their cached copy of the script, which they’ll have if they’ve ever visited your site before.Basically, if the file ‘public/javascripts/myscript.js’ exists, then
evanluates to
where
CHECKSUMis either the last modification date of the file or a checksum of its contents (I’m not sure which – suffice it to say that the value will change whenever the file changes, tricking browsers into downloading the new script).If the javascript file in question isn’t on your server (say you’re pulling jQuery from Google APIs), then Rails won’t know how to generate the checksum, and the result will come out looking like a regular
<script>tag (without the?CHECKSUMbit).So there’s no reason to use
javascript_include_tagon scripts you’re not hosting yourself. But if you have your own custom script files – and especially if these will be changed with even moderate frequency – then you should probably look into using it; it’s a convenient way to make sure everyone is seeing the true current version of the site.Hope this helps!