Skip to content

Instantly share code, notes, and snippets.

@topher6345
Created November 30, 2014 02:29
Show Gist options
  • Save topher6345/938e5b487a6ea67d8403 to your computer and use it in GitHub Desktop.
Save topher6345/938e5b487a6ea67d8403 to your computer and use it in GitHub Desktop.
Uglify Javascripts in a Jekyll Project.
require 'uglifier'
Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p }
.each do |file|
next unless file[/\.js/]
compressed = Uglifier.compile(
File.read(file)
)
File.open(file, 'w') { |newfile| newfile.write(compressed) }
puts "#{file} uglified."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment