Module: Squoosh

Defined in:
lib/squoosh.rb,
lib/squoosh/version.rb

Overview

Minify HTML, JavaScript, and CSS.

Examples

html = <<-EOF
<!DOCTYPE html>
<html>
  <head>
    <!-- Set the title -->
    <title>My fancy title!</title>
  </head>
  <body>
    <p>Two</p>
    <p>paragraphs.</p>
  </body>
</html>
EOF
compressed = Squoosh.minify_html(html)
# "<!DOCTYPE html><title>My fancy title!</title><p>Two<p>paragraphs."

Author:

Defined Under Namespace

Classes: Squoosher

Constant Summary collapse

VERSION =

The version of squoosh.

'0.4.1'

Class Method Summary collapse

Class Method Details

.minify_css(content, options = {}) ⇒ String

Minify CSS convenience method.

Parameters:

  • content (String)

    the CSS to minify

  • options (Hash) (defaults to: {})

    options to override the Squoosher default options

Returns:

  • (String)

    the minified CSS



682
683
684
# File 'lib/squoosh.rb', line 682

def self.minify_css(content, options = {})
  Squoosher.new(options).minify_css content
end

.minify_html(content, options = {}) ⇒ String

Minify HTML convenience method.

Parameters:

  • content (String)

    the HTML to minify

  • options (Hash) (defaults to: {})

    options to override the Squoosher default options

Returns:

  • (String)

    the minified HTML



673
674
675
# File 'lib/squoosh.rb', line 673

def self.minify_html(content, options = {})
  Squoosher.new(options).minify_html content
end

.minify_js(content, options = {}) ⇒ String

Minify JavaScript convenience method.

Parameters:

  • content (String)

    the JavaScript to minify

  • options (Hash) (defaults to: {})

    options to override the Squoosher default options

Returns:

  • (String)

    the minified JavaScript



691
692
693
# File 'lib/squoosh.rb', line 691

def self.minify_js(content, options = {})
  Squoosher.new(options).minify_js content
end