Socket
Book a DemoInstallSign in
Socket

layzr-rails

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

layzr-rails

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Layzr-Rails

This project integrates the jQuery Layzr Plugin for Rails image_tag helpers

What's jQuery Layzr Plugin?

From the project page:

A small, fast, and modern library for lazy loading images.

See live demo

Documentation

Installation

Add it in your gemfile

gem 'layzr-rails'

Create a configuration file and put it in your initializers config/initializers/layzr.rb

  Layzr::Rails.configure do |config|
    config.placeholder = "/assets/some-default-image.png"
  end

Require layzr library in application.js ie:

//= require layzr

And place the jvascript code:

$(document).ready(function() {
   const instance = Layzr()
});

Features

  • Add lazy: true option to Rails image_tag helpers to render layzr-friendly img tags.
  • Simple (really). That's pretty much it.

Example

<%= image_tag "kittenz.png", alt: "OMG a cat!", lazy: true %>

Equals:

<img alt="OMG a cat!" data-normal="/images/kittenz.png" src="/assets/some-default-image.png">

More options

<%= image_tag "normal.jpg", lazy: true, layzr: { retina: "retina.jpg", srcset: "small.jpg 320w, medium.jpg 768w, large.jpg 1024w"} %>

Equals:

<img src="/assets/some-default-image.png" data-normal="normal.jpg" data-retina="retina.jpg" data-srcset="small.jpg 320w, medium.jpg 768w, large.jpg 1024w">  

License

Layzr-Rails is released under the MIT License.

FAQs

Package last updated on 07 Feb 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.