Optipipe
Optipipe enables you to correspond to load only required assets, load assets lazy, and so on, about precompiled files.
Specifically, Optipipe provide following functions.
- Structure of directories to manage using some precompiled assets and being easy to understand dependencies of assets (principally javascripts).
- A funcion that load only required asset files.
- A funcion that configure lazyloading asset files that have no problem even if load after
onload.
A funcion that load lazy asset files that have no problem even if load after onload
Optipipe enables you to fix your web application's performance by these funtions, when use HTTP/2 protocol.
Read this in other languages: 日本語
Installation
Add this line to your application's Gemfile:
gem 'optipipe'
And then execute:
$ bundle
And then run initial settings:
$ rails g optipipe:install
Configure
Running initial settings create files and directories like following structure.
app/assets/
All files created initial is sample, please rewriting or delete.
BasicUsage
Helper
Run helper method like following in layout's view files, and you can load asset files each controllers.
<%= optipipe_javascript_include_tag %>
<%= optipipe_stylesheet_link_tag %>
You can configure like following using default mapper when there aren't any mappers meeting a condition. This value is controller_path.
<%= optipipe_javascript_include_tag(default: 'welcome') %>
You can configure mapper's additional conditions by arguments like following.
<%= optipipe_javascript_include_tag(device: 'pc') %>
controller_path: 'welcome'
load_files:
- example_precompile
after_onload:
- example_precompile_after_onload
device: 'pc'
Mapper
You can configure precompiled asset files each controllers by Mapper.
controller_path
Please set controller path.
If use controller with namespace, join /. (same value of controller_path in ActionController.)
load_files
Please set precompiled asset file's names.
Files exist at under optipipe/precompiles.
after_onload
Please set asset file's names loaded after onload on javascript.
Files exist at under optipipe/precompiles.
This setting is only Javascript's Mapper.
License
The gem is available as open source under the terms of the MIT License.