I am writing a Rails 3.1 mounted engine that adds functions to the main application (i.e. it is not isolated). The JS engine depends on jQuery , jQueryUI , DataTables, and JSTree (among other libraries), so the engine manifest looks something like this:
Then I can conditionally load this file into the main application layout using:
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'my_engine/my_engine' if user_logged_in? %>
However, if the main manifest of the application already includes one of the dependencies (most likely jQuery and jQuery_UJS), then these dependencies will be loaded twice. I will see something like:
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
...
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script>
<script src="/assets/jstree_pre1.0_fix_1/jquery.jstree.js?body=1" type="text/javascript"></script>
...
<script src="/assets/cms/application.js?body=1" type="text/javascript"></script>
Sprocket require , . , , , , , . Sprockets?