izi_lightup 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/critical_helper.rb +19 -8
- data/lib/izi_lightup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8f79dcdf158759fc11c0b29c8b8a97b54c250c42ba80df355a82a605df2740a
|
4
|
+
data.tar.gz: 523adf5e981759cef50da8418dcc167c8cf6cee7beb11f62cf1c3eab82a05468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e1d85ee87b1af74d7e8d580950271585126bcfde37f381a912d220130fa9f0ae7d98ac1b41e102115f0674b0672dede6d88db363c83d574766a0f8787cbea35
|
7
|
+
data.tar.gz: e6cd686fc83af4063aed999def9fcddcab442f0954f784f03ad3ec26c88b7b9f5cf0a52297c66c32e7c17a1900b141323ff2b2b6cf7fe0df1dab56284171388b
|
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module CriticalHelper
|
4
|
-
def css_preload(
|
5
|
-
|
4
|
+
def css_preload(names)
|
5
|
+
return '' if names.blank?
|
6
|
+
names = Array.wrap(names)
|
7
|
+
|
8
|
+
link = stylesheet_link_tag(*names, rel: 'preload', as: 'style', onload: 'this.rel="stylesheet"')
|
6
9
|
noscript = content_tag :noscript do
|
7
|
-
|
10
|
+
stylesheet_link_tag(*names)
|
8
11
|
end
|
9
12
|
|
10
13
|
link + noscript
|
@@ -24,14 +27,22 @@ module CriticalHelper
|
|
24
27
|
inline_js('crit-utils/bundle.js').presence || '<!-- CRIT JS NOT FOUND! -->'.html_safe
|
25
28
|
end
|
26
29
|
|
27
|
-
def critical_css
|
30
|
+
def critical_css(params = {})
|
28
31
|
name = find_scoped_css('critical')
|
29
|
-
|
32
|
+
stylesheets = Array.wrap(params.fetch(:stylesheets, []))
|
33
|
+
data = StringIO.new
|
30
34
|
|
31
|
-
|
35
|
+
if name.blank?
|
36
|
+
# insert stylesheets directly if not crit css
|
37
|
+
data << '<!-- CRIT CSS NOT FOUND! -->'
|
38
|
+
data << stylesheet_link_tag(*stylesheets) if stylesheets.present?
|
39
|
+
else
|
40
|
+
data << inline_css(name)
|
41
|
+
data << css_preload(stylesheets) if stylesheets.present?
|
42
|
+
data << inline_js('crit-utils/measure.js') if Rails.env.development?
|
43
|
+
end
|
32
44
|
|
33
|
-
|
34
|
-
inline_css(name) + inline_js('crit-utils/measure.js')
|
45
|
+
data.string.html_safe
|
35
46
|
end
|
36
47
|
|
37
48
|
def smart_picture(object, *args, **xargs, &block)
|
data/lib/izi_lightup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: izi_lightup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IzikAJ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Utils to speed up page load by using critical css &
|