First, you will need to run the customization generator
will generate an
rrt.js file, which contains the imports for all external
libraries. You can now edit that file to remove anything you don't need, but be
sure to not remove Bootstrap itself - unless you really mean to.
Next, take a look at the view partial in
views/layouts/_external_js_libs.html.erb. This contains code which handles the
loading of particularly heavy JS libraries:
You can remove whichever libraries you don't intend to use.
Finally, in the
views/layouts/_base layout there are special tags on the
body element under the
data-js-libs data attribute. Remove any of the
default libraries from this attribute that you don't need. Search your project
for the string
content_for :js_libs and review any additional JS libs that are
loaded on a per-view basis that you might not want (dashboard demo libraries for
This allows you to specify exactly those libraries which should be rendered out before everything else, or are otherwise not part of your asset pipeline manifest in
Let's say you have a specific page that you want to load Google Maps on, and only that page. To have the appropriate external JS libs be rendered to the output, you'd need to include the following on that specific page:
<% content_for :js_libs, "gmaps" %>
This will cause the Google Maps include tag to be rendered in
All you have to do is place the
@js_libs instance variable for inclusion of a library name you specified in your
content_for :js_libs tag:
That block of code would be rendered when a
content_for :js_libs, 'chartjs' tag is encountered on a page.
In this case I've also chosen to have the
include tags rendered into the
:external_js_libs content placeholder.
Once you run the customization generator as above, you can simply remove all
require statements that reference