Skip to content

Commit 6400619

Browse files
committed
Merge parent repo
2 parents ca1823d + 73a18a3 commit 6400619

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ To load the generated critical CSS into your layout, in the head tag, insert:
6464

6565
```HTML+ERB
6666
<style>
67-
<%= CriticalPathCss.fetch(request.path) %>
67+
<%= CriticalPathCss.fetch(request.path) %>
6868
</style>
6969
```
7070

@@ -74,9 +74,12 @@ A simple example using [loadcss-rails](https://github.com/michael-misshore/loadc
7474
<style>
7575
<%= CriticalPathCss.fetch(request.path) %>
7676
</style>
77-
<%= tag :link, as: 'style', href: stylesheet_path('application'), onload: raw("this.rel='stylesheet'"), rel: 'preload' %>
77+
<script>
78+
loadCSS("<%= stylesheet_path('application') %>");
79+
</script>
80+
<link rel="preload" href="<%= stylesheet_path('application') %>" as="style" onload="this.rel='stylesheet'">
7881
<noscript>
79-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
82+
<link rel="stylesheet" href="<%= stylesheet_path('application') %>">
8083
</noscript>
8184
```
8285

lib/critical-path-css-rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.generate(route)
99

1010
def self.generate_all
1111
CssFetcher.new.fetch.each do |route, css|
12-
Rails.cache.write(route, css, namespace: CACHE_NAMESPACE)
12+
Rails.cache.write(route, css, namespace: CACHE_NAMESPACE, expires_in: nil)
1313
end
1414
end
1515

0 commit comments

Comments
 (0)