No commit activity in last 3 years
No release in over 3 years
Very fast jsmin implementation using FFI
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0.3.5
 Project Readme

FFI Javascript minifier

Description

This library was created in order to provide a reasonably fast Javascript
minifier on JRuby platform.
Both native Java and Ruby implementations were found to be in several orders
of magnitude slower.
The only change from the original C implementation, is that it was changed
to C++ (in order to make global variables become instance variables),
and it works with buffers rather than stdin/stdout now.

Synopsis

 require 'jsmin_ffi'
 input = IO.read('prototype.js')
 begin
   output = JsminFFI.minify!(input)
   File.open('output.js', 'w') {|f| f.write(output)}
 rescue Jsmin::ParseError => e
   $stderr.puts "Cannot minify: #{e}"
 end

or use a native extension:


require ‘Jsmin’
input = IO.read(‘jquery.js’)
begin
output = Jsmin.minify(input)
File.open(‘output.js’, ‘w’) {|f| f.write(output)}
rescue Jsmin::ParseError => e
$stderr.puts “Cannot minify: #{e}”
end

Bugs

The memory allocated in the C++ code might not be freed when using FFI.
It depends on how FFI handles the returned char*.

See also

For the original implementation, please see:
http://www.crockford.com/javascript/jsmin.html