Skip to content

Instantly share code, notes, and snippets.

@pchaigno
Created October 6, 2014 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pchaigno/8c7b66a6b093e6c7b97f to your computer and use it in GitHub Desktop.
Save pchaigno/8c7b66a6b093e6c7b97f to your computer and use it in GitHub Desktop.
Median line length for minified files
def minified_files?
return unless ['.js', '.css'].include? extname
if lines.any?
median = lines.sort_by { |l| l.length}[lines.length / 2].length
puts "median line length: #{median}\n"
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 110
else
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment