0.0
No commit activity in last 3 years
No release in over 3 years
It is very easy to enable lazy loading of partial with scroll in views
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4.2.2
 Project Readme

StepRender

It is very easy to enable lazy loading of partial with scroll in views.

You only use step_render method instead of render method.

Likewise, you can lazy load a fragment cache.

Installation

Add this line to your application's Gemfile:

gem 'step_render'

And then execute:

$ bundle

Usage 1: Lazy Load Partial

1. Load javascript library

This plugin depends on lazysizes. If you do not import lazysizes to your application, load import_step_render method in required view.

Example

application.html.erb

<head>
  ~~~
  ~~~
  <%= import_step_render %>
  ~~~
</head>

2. Add to routing

Add the following line to the routes.rb.

Example

routes.rb

Rails.application.routes.draw do
  ~~~
  mount_step_render
  ~~~

3. Use step_render method instead of render method

Replace render helper method used to rendering the partial with step_render. Partial must be specified as an absolute path.

Example

app/views/top/index.html.erb

<%= step_render 'top/partial_name' %>

Usage 2: Lazy Load fragment cache

1. Load javascript library

2. Add to routing

3. Use step_cache method instead of cache method

Replace cache helper method used to fragment cache with step_render.

Example

app/views/top/index.html.erb

<%= step_cache 'cache_key', skip_digest: true, expires_in: 24.hours %>
  ~~~
  ~~~html tags

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.