2

I'm having trouble right now trying to make sure that my images are optimized. I've manually optimized every image that I can, and I found this handy gem in combination with this to automate the process in future.

I have two remaining images that pagespeed is warning me about, and those are compass generated sprite files. While the image_optim gem is great, it's not compressing the generated images.

I've already forked the heroku ruby buildpack to modify it for other reasons, so I'm open to solutions involving that. I did try this:

log("image_optim") do
  sprite_path = Dir["#{Rails.root.join('public', 'assets').to_s}/sprite-*.png"]
  image_optim = ImageOptim.new
  image_optim.optimize_images!(sprite_path)
end

But I ended up getting this error, which seemed unrelated to me, but it was definitely this code that triggered it:

/tmp/buildpack_f3d33d60-fd28-45d8-ac44-d1878918103e/lib/language_pack/rails4.rb:124:in `block in run_assets_precompile_rake_task': uninitialized constant LanguagePack::Rails4::Rails (NameError)

Any help would be appreciated!

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
Eric Roberts
  • 285
  • 2
  • 11

0 Answers0