Skip to content

Instantly share code, notes, and snippets.

Tom Aranda taranda

Block or report user

Report or block taranda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@taranda
taranda / dynamic-critical-path-css.md
Last active May 9, 2019
Dynamically Add Critical CSS to Your Rails App
View dynamic-critical-path-css.md

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

You can’t perform that action at this time.