Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I do not think there is one best practice, but I'll let you know what I do.</p> <ol> <li><p>I have a series of js files each for with their own purpose in the <code>public/javascripts/</code> directory. Some examples could be <code>utility.js</code> <code>chat.js</code> <code>shopping_basket.js</code> and so on. </p></li> <li><p>I use <a href="http://github.com/sbecker/asset_packager" rel="nofollow noreferrer">asset packager</a> and define one big fat collection for all my general use functionality and another for admin only functionality. Round trips to the server cost way too much. I basically include all the js in on first page load minified into one blob (in general) </p></li> <li><p>I allow basic <code>$(document).ready</code> hooks inline in the pages, and keep them really short.</p></li> <li><p>Data that my js files needs to access is rendered inline with the page. (Usually in the DOM, sometimes as vars - Eg. <code>var xyz = 100</code>)</p></li> <li><p>I will usually develop my controllers with javascript off (and make sure it all works), then I turn it on and sprinkle a few <code>if request.xhr?</code> where needed.</p></li> </ol> <hr> <p>Keep in mind, Rail 3.1 introduces a built-in best practice, see: <a href="http://guides.rubyonrails.org/asset_pipeline.html" rel="nofollow noreferrer">http://guides.rubyonrails.org/asset_pipeline.html</a> - on a personal note I have had performance and configuration issues with the new pipeline, however many others have had great success with it. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload