izi_lightup 1.0.4 → 1.0.9

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: f8f79dcdf158759fc11c0b29c8b8a97b54c250c42ba80df355a82a605df2740a
4
- data.tar.gz: 523adf5e981759cef50da8418dcc167c8cf6cee7beb11f62cf1c3eab82a05468
3
+ metadata.gz: 42f8d61f9ec4c7084a86d25b94406a90f50e143f8321019baa55c371c99f9954
4
+ data.tar.gz: 1b69afac25575f41dc28f2b58f738e72da421324a9686d4741f1780a10684110
5
5
  SHA512:
6
- metadata.gz: 5e1d85ee87b1af74d7e8d580950271585126bcfde37f381a912d220130fa9f0ae7d98ac1b41e102115f0674b0672dede6d88db363c83d574766a0f8787cbea35
7
- data.tar.gz: e6cd686fc83af4063aed999def9fcddcab442f0954f784f03ad3ec26c88b7b9f5cf0a52297c66c32e7c17a1900b141323ff2b2b6cf7fe0df1dab56284171388b
6
+ metadata.gz: eaa3f189c8f6dbe98b57d46b24a445f5be051a96eab836de9665b5d6984422de4f3915fe482100d198bac3290ec7049c214d64946964784314efcf8e8b239d0c
7
+ data.tar.gz: d15c0663e94f3daa8059c5cfb25f2eaa98874c3d36f65608ab2d542649c7d32ae3ac060bcc56e210e94c4a2b0f5da9a6672ce309f7c20e5b25f08b3553b3bcde
@@ -1,6 +1,6 @@
1
1
  ((window, document) -> (
2
2
  EVENT_TYPE = window.__activeEventName || 'Activity'
3
- MAX_TIMEOUT = window.__activeTimeout || 5000
3
+ MAX_TIMEOUT = window.__activeTimeout || 10000
4
4
  TRACK_MARKING = window.__activeMark || '_real_track=true'
5
5
 
6
6
  if custom_mt = /^\?(\d+)$/.exec(window.location.search)
@@ -1,2 +1,3 @@
1
- //= require cssrelpreload.js
1
+ // loadCSS should be always BEFORE cssrelpreload
2
2
  //= require loadCSS.js
3
+ //= require cssrelpreload.js
@@ -15,7 +15,6 @@
15
15
  _buildSubscriptions = (id, node) ->
16
16
  data = __required[id]
17
17
  return if data.loaded
18
- data.callbacks ||= []
19
18
 
20
19
  callback = node.onload
21
20
  node.onload = -> _onload(id)
@@ -34,13 +33,16 @@
34
33
 
35
34
  window.miniRequire ||= (key, source_url, callback = undefined) ->
36
35
  id = "source_#{key.replace(/[^a-z0-9_\-]+/ig, '_')}"
36
+ __required[id] ||= {loaded: false, callbacks: [], started: false}
37
37
 
38
- # subscribe only if already attached
39
- return _subscribe(id, callback) if __required[id]?
40
-
41
- __required[id] = {loaded: false, callbacks: []}
42
38
  # subscribe only if no source
43
- return _subscribe(id, callback) unless source_url?
39
+ return _subscribe(id, callback) unless source_url?.length > 0
40
+
41
+ # subscribe only if already attached & started
42
+ return _subscribe(id, callback) if __required[id].started
43
+
44
+ # mark as started
45
+ __required[id].started = true
44
46
 
45
47
  # attach script
46
48
  src = document.createElement('script')
@@ -53,4 +55,29 @@
53
55
 
54
56
  document.body.appendChild(src)
55
57
  true
58
+
59
+ window.miniPreload ||= (key, source_url, callback = undefined) ->
60
+ id = "source_#{key.replace(/[^a-z0-9_\-]+/ig, '_')}"
61
+ __required[id] ||= {loaded: false, callbacks: [], started: false}
62
+
63
+ # subscribe only if no source
64
+ return _subscribe(id, callback) unless source_url?.length > 0
65
+
66
+ # subscribe only if already attached & started
67
+ return _subscribe(id, callback) if __required[id].started
68
+
69
+ # mark as started
70
+ __required[id].started = true
71
+
72
+ # attach script
73
+ src = document.createElement('link')
74
+ src.id = id
75
+ src.rel = 'preload'
76
+ src.href = source_url
77
+ _buildSubscriptions(id, src)
78
+ _subscribe(id, callback)
79
+
80
+ document.head.appendChild(src)
81
+ true
82
+
56
83
  ))(window, document)
@@ -28,7 +28,8 @@ module CriticalHelper
28
28
  end
29
29
 
30
30
  def critical_css(params = {})
31
- name = find_scoped_css('critical')
31
+ scope = params.fetch(:scope, 'critical')
32
+ name = find_scoped_css(scope)
32
33
  stylesheets = Array.wrap(params.fetch(:stylesheets, []))
33
34
  data = StringIO.new
34
35
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziLightup
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.9'
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.4
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - IzikAJ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-05 00:00:00.000000000 Z
11
+ date: 2020-12-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Utils to speed up page load by using critical css &
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  requirements: []
57
- rubygems_version: 3.0.3
57
+ rubygems_version: 3.1.2
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: Izi Lightup