A simple ruby wrapper for the phenominal Polyfill.io Service by FTLabs for Rails applications.
The library provides a simple view helper to load in the polyfills. Simply in any view file add the polyfills
call. Make sure to load it prior to running any other javascript. Here's an example app/views/layouts/welcome.erb
:
<html>
<head>
<title>Welcome</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= csrf_meta_tokens %>
</head>
<body>
<%= yield %>
<%= polyfills %>
<%= javascript_include_tag 'application' %>
</body>
</html>
Add the gem to your Gemfile: gem "polyfillrb", "~>1.1.0"
- Cache polyfills to avoid node IO calls (especially in production)
- Ensure we are doing the most performant javascript executions.