I have included the gem gmaps4rails
. I wanted to display some markers (3 to be exact) and their infowindow on a maps but this gems come with a lot of js library and it slow my site' load.
I only wants theses library on only one page. I d'like to know how can removed some unnecessary js library.
<script src="/assets/underscore.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/base.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/base/base.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/objects/base_builder.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/objects/builder.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/objects/handler.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/objects/null_clusterer.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/common.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/bound.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/circle.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/clusterer.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/kml.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/map.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/marker.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/polygon.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/builders/polyline.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/bound.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/circle.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/clusterer.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/kml.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/map.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/marker.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/polygon.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/objects/polyline.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google/primitives.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps/google.js?body=1" type="text/javascript"></script>
Each file is quite small so the list seems huge but its few code. So maybe in development in slows things down the first time they have to be rendered but then they are cached.
In production, they'll be compressed inside your application.js so there presence would be hardly noticeable.
If you still dont want them inside each page:
remove the require of gmaps4rails and underscore in application.js
include files in the page where they are required using a CDN like: http://cdnjs.com/libraries/gmaps4rails