izi_lightup 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90b753cd65a5809c20e73ff45888da3522becc09c96cc201716f559f9cc4ee6e
4
- data.tar.gz: 2a7081b56841e5d53c9f792ff17f7becdeef6f7eeb062d23a9d48067904ffbb5
3
+ metadata.gz: f8f79dcdf158759fc11c0b29c8b8a97b54c250c42ba80df355a82a605df2740a
4
+ data.tar.gz: 523adf5e981759cef50da8418dcc167c8cf6cee7beb11f62cf1c3eab82a05468
5
5
  SHA512:
6
- metadata.gz: cb847e6b534e9b4796078be0ec691a8eeb530bbad14b1c964c8a138b6ebb5166642dfbf3d85e25bbfa25eeb397f98c7ab9fee2efc6bbea2c51036c226fe60d27
7
- data.tar.gz: aab2c944301d19dda2f2a088059a2c2bd63d509470b5ae8aebbb203fa474d87d8eb1803a98cf179128aa6e585074f2ef7cf41275a033fc6fb8eecafd50fb0513
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(name)
5
- link = content_tag :link, '', rel: 'preload', href: stylesheet_path(name), as: 'style', onload: 'this.rel="stylesheet"'
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
- content_tag :link, '', rel: 'stylesheet', href: stylesheet_path(name)
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
- return '<!-- CRIT CSS NOT FOUND! -->'.html_safe if name.blank?
32
+ stylesheets = Array.wrap(params.fetch(:stylesheets, []))
33
+ data = StringIO.new
30
34
 
31
- return inline_css(name) if Rails.env.production?
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
- # inject measure js for development
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziLightup
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
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.3
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-09-04 00:00:00.000000000 Z
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 &