Lazyloadjs
Implementing LazyLoad ( http://github.com/fasterize/lazyload ) for Ruby on Rails
Installation
Add this line to your application's Gemfile:
gem 'lazyloadjs'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lazyloadjs
Usage
In your application.js
:
...
//= require lazyload
...
Restart your application. Lazy load is now availlable.
This gem provide simple helper generate requiered attributes in the img tag :
image_lazy 'https://upload.wikimedi....png'
# => <img data-frz-src="https://upload.wikimedi....png" src="data:ima..." onload="lzld(this)" onerror="lzld(this)" />
image_lazy 'https://upload.wikimedi....png', alt: "Google logo"
# => <img data-frz-src="https://upload.wikimedi....png" src="data:ima..." onload="lzld(this)" onerror="lzld(this)" alt="Google logo" />
# etc.
Contributing
- Fork it ( http://github.com/angelodlfrtr/lazyloadjs/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request