1
|
|
|
/** |
2
|
|
|
The following polyfill function is meant to run in the browser and adapted from |
3
|
|
|
https://github.com/guybedford/es-module-shims |
4
|
|
|
MIT License |
5
|
|
|
Copyright (C) 2018-2021 Guy Bedford |
6
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
7
|
|
|
of this software and associated documentation files (the "Software"), to deal |
8
|
|
|
in the Software without restriction, including without limitation the rights |
9
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10
|
|
|
copies of the Software, and to permit persons to whom the Software is |
11
|
|
|
furnished to do so, subject to the following conditions: |
12
|
|
|
The above copyright notice and this permission notice shall be included in all |
13
|
|
|
copies or substantial portions of the Software. |
14
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
19
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
(function() { |
|
|
|
|
23
|
|
|
const relList = document.createElement('link').relList; |
|
|
|
|
24
|
|
|
if (relList && relList.supports && relList.supports('modulepreload')) { |
|
|
|
|
25
|
|
|
return; |
|
|
|
|
26
|
|
|
} |
|
|
|
|
27
|
|
|
|
28
|
|
|
for (const link of document.querySelectorAll('link[rel="modulepreload"]')) { |
|
|
|
|
29
|
|
|
processPreload(link); |
|
|
|
|
30
|
|
|
} |
|
|
|
|
31
|
|
|
|
32
|
|
|
new MutationObserver(mutations => { |
|
|
|
|
33
|
|
|
for (const mutation of mutations) { |
|
|
|
|
34
|
|
|
if (mutation.type !== 'childList') continue; |
|
|
|
|
35
|
|
|
for (const node of mutation.addedNodes) { |
|
|
|
|
36
|
|
|
if (node.tagName === 'LINK' && node.rel === 'modulepreload') |
|
|
|
|
37
|
|
|
processPreload(node); |
|
|
|
|
38
|
|
|
else if (node.querySelectorAll) { |
|
|
|
|
39
|
|
|
for (const link of node.querySelectorAll('link[rel=modulepreload]')) { |
|
|
|
|
40
|
|
|
processPreload(link); |
|
|
|
|
41
|
|
|
} |
|
|
|
|
42
|
|
|
} |
|
|
|
|
43
|
|
|
} |
|
|
|
|
44
|
|
|
} |
|
|
|
|
45
|
|
|
}).observe(document, { childList: true, subtree: true }); |
|
|
|
|
46
|
|
|
|
47
|
|
|
function getFetchOpts (script) { |
|
|
|
|
48
|
|
|
const fetchOpts = {}; |
|
|
|
|
49
|
|
|
if (script.integrity) |
|
|
|
|
50
|
|
|
fetchOpts.integrity = script.integrity; |
|
|
|
|
51
|
|
|
if (script.referrerpolicy) |
|
|
|
|
52
|
|
|
fetchOpts.referrerPolicy = script.referrerpolicy; |
|
|
|
|
53
|
|
|
if (script.crossorigin === 'use-credentials') |
|
|
|
|
54
|
|
|
fetchOpts.credentials = 'include'; |
|
|
|
|
55
|
|
|
else if (script.crossorigin === 'anonymous') |
|
|
|
|
56
|
|
|
fetchOpts.credentials = 'omit'; |
|
|
|
|
57
|
|
|
else |
|
|
|
|
58
|
|
|
fetchOpts.credentials = 'same-origin'; |
|
|
|
|
59
|
|
|
return fetchOpts; |
|
|
|
|
60
|
|
|
} |
|
|
|
|
61
|
|
|
|
62
|
|
|
function processPreload(script) { |
|
|
|
|
63
|
|
|
if (script.ep) { |
|
|
|
|
64
|
|
|
// ep marker = processed |
|
|
|
|
65
|
|
|
return; |
|
|
|
|
66
|
|
|
} |
|
|
|
|
67
|
|
|
script.ep = true; |
|
|
|
|
68
|
|
|
// prepopulate the load record |
|
|
|
|
69
|
|
|
const fetchOpts = getFetchOpts(script); |
|
|
|
|
70
|
|
|
fetch(script.href, fetchOpts); |
|
|
|
|
71
|
|
|
} |
|
|
|
|
72
|
|
|
}()); |
73
|
|
|
|