0.0
No commit activity in last 3 years
No release in over 3 years
optimize-js makes JavaScript scripts initialize faster. This gem provides Ruby and Rails asset pipeline integration for optimize-js.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 1.7
~> 10.0
~> 3.1

Runtime

>= 1
 Project Readme

Ruby wrapper and Rails asset pipeline integration for optimize-js.

Gem Version Build Status

About

This gem is ruby wrapper for optimize-js. It allows you to invoke optimize-js from ruby. For Rails users this gem automatically integrates optimize-js into sprockets.

Installing gem

If you are using bundler.
Add to your Gemfile:

gem 'optimize-js', '~> 1.0'

If you are not using bundler.
Run in your terminal:

gem install optimize-js

Require gem in your ruby sources:

require 'optimize-js'

Using gem

API is quite simple.

# OptimizeJS.perform(javascript_source, optimize_js_options)

OptimizeJS.perform('!function() {}()') # => !(function() {})()

Using in Rails

There is no need to do anything.
Gem will automatically register OptimizeJS::SprocketsProcessor using register_bundle_processor so all your JavaScript assets will be optimized.

Updating optimize-js to the latest version

  1. Install gem dependencies: bundle install
  2. Run: bundle exec rake optimize_js

This rake task will do several things:

  1. Clone latest git tag
  2. Install npm dependencies
  3. Install browserify
  4. Install uglifyjs
  5. Make web-version
  6. Minify web-version
  7. Write version to optimize-js/version.rb
  8. Cleanup

Running tests

  1. Install gem dependencies: bundle install
  2. Run tests: bundle exec rake test

Things to work on

  1. Write integration tests.
  2. Test on different versions of sprockets.
  3. Test on different versions of rails.
  4. Test on different versions of ruby.
  5. Sprockets without Rails.
  6. Typos in README.

Licence

JavaScript Library Licence
Ruby Gem Licence