Posted 26 days ago. Visible to the public. Auto-destruct in 44 days

Updated: Unpoly: Loading large libraries on-demand

Rails asset pipeline

As in newer Rails all assets are precompiled and the path above /huge-lib.js will at least not exist in production. Here is our preferred way to solve this:

1. Copy the large library to your vendor folder e.g. vendor/asset-libs/huge-lib/huge-lib.js

2. Create a new file e.g. app/assets/javascripts/huge-lib.js with the following content:

//= require huge-lib.js

3. Allow this file to be precompiled by adding the following line to your config/application.rb

config.assets.precompile += ['huge-lib.js']

4. Finally change the compiler from e.g. map.js to map.js.erb and use the asset_path helper:

hugeLibraryLoaded = hugeLibraryLoaded || $.getScript('<%= asset_path('huge-lib', type: :javascript) %>')

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Author of this card:

Emanuel De
Last edit:
16 days ago
by Emanuel De
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Emanuel De to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more