AssetsLedger

Keep track of JS/CSS dependencies and makes sure they are only included once.

Installation

Add this line to your application's Gemfile:

gem 'assets_ledger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install assets_ledger

Usage

ledger = AssetsLedger::Ledger.new
ledger.add_js('path/to/js')
ledger.add_css('path/to/css')

# You can add many dependencies at once
ledger.add_js('/js/jquery.js', 'js/jquery.datatables.js')

# or pass an array
js_dependencies = ['/js/jquery.js', 'js/jquery.datatables.js']
ledger.add_js(js_dependencies)

if you use Rails you can generate the include tags by:

# In application.html.erb
stylesheet_link_tag *ledger.css_dependencies
# ...
javascript_include_tag *ledger.js_dependencies

Contributing

  1. Fork it ( https://github.com/trialbee/assets_ledger/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request