Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unveil-rails

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unveil-rails

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Unveil.js for Rails

Lazy loaded images on rails. If you want a quick start using unveil.js with rails there is now a gem for that.

By loading your images as they appear in the viewport rather than on load you can improve your rails application's page speed.

Installation

Add the unveil-rails gem into your Gemfile:

gem 'unveil-rails', '~> 0.2.1'

Install unveil.js and initializer into your rails app:

bin/rails g unveil:rails:install

Include the unveil.js initializer in app/assets/javascripts/application.js:

//= require unveil_init

Now use the helper method where ever you want lazy images:

<%= lazy_image_tag('an-image.png') %>
<%= lazy_image_tag('an-image.png', retina: 'a-retina-image.png') %>
<%= lazy_image_tag('an-image.png', placeholder: 'placeholder.png') %>

Configuration

The installation generator will have added an initializer to your application. In this file there are a couple of settings you can change.

Threshold

Unveil::Rails.config.threshold = 200

Setting this variable to an integer will set the unveil threshold setting as documented here.

Default placeholder

You may set an alternative default placeholder image:

Unveil::Rails.config.default_placeholder = 'default.jpg'

You can set the placeholder per lazy image by passing in the placeholder option:

<%= lazy_image_tag('an-image.png', placeholder: 'placeholder.png') %>

Credits

made

Developed and maintained by Made Tech. Key contributions:

And of course Luís Almeida creator of unveil.js.

License

Copyright © 2014 Made Tech Ltd. It is free software, and may be redistributed under the terms specified in the LICENSE file.

FAQs

Package last updated on 21 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc