unhead 1.9.4 → 1.9.5
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.
- package/dist/index.cjs +10 -1
- package/dist/index.mjs +10 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -452,6 +452,7 @@ function useScript(_input, _options) {
|
|
|
452
452
|
const head = options.head || getActiveHead();
|
|
453
453
|
if (!head)
|
|
454
454
|
throw new Error("Missing Unhead context.");
|
|
455
|
+
const isAbsolute = input.src && (input.src.startsWith("http") || input.src.startsWith("//"));
|
|
455
456
|
const id = input.key || shared.hashCode(input.src || (typeof input.innerHTML === "string" ? input.innerHTML : ""));
|
|
456
457
|
const key = `use-script.${id}`;
|
|
457
458
|
if (head._scripts?.[id])
|
|
@@ -495,8 +496,16 @@ function useScript(_input, _options) {
|
|
|
495
496
|
load() {
|
|
496
497
|
if (!script.entry) {
|
|
497
498
|
syncStatus("loading");
|
|
499
|
+
const defaults = {
|
|
500
|
+
defer: true,
|
|
501
|
+
fetchpriority: "low"
|
|
502
|
+
};
|
|
503
|
+
if (isAbsolute) {
|
|
504
|
+
defaults.crossorigin = "anonymous";
|
|
505
|
+
defaults.referrerpolicy = "no-referrer";
|
|
506
|
+
}
|
|
498
507
|
script.entry = head.push({
|
|
499
|
-
script: [{
|
|
508
|
+
script: [{ ...defaults, ...input, key }]
|
|
500
509
|
}, options);
|
|
501
510
|
}
|
|
502
511
|
return loadPromise;
|
package/dist/index.mjs
CHANGED
|
@@ -451,6 +451,7 @@ function useScript(_input, _options) {
|
|
|
451
451
|
const head = options.head || getActiveHead();
|
|
452
452
|
if (!head)
|
|
453
453
|
throw new Error("Missing Unhead context.");
|
|
454
|
+
const isAbsolute = input.src && (input.src.startsWith("http") || input.src.startsWith("//"));
|
|
454
455
|
const id = input.key || hashCode(input.src || (typeof input.innerHTML === "string" ? input.innerHTML : ""));
|
|
455
456
|
const key = `use-script.${id}`;
|
|
456
457
|
if (head._scripts?.[id])
|
|
@@ -494,8 +495,16 @@ function useScript(_input, _options) {
|
|
|
494
495
|
load() {
|
|
495
496
|
if (!script.entry) {
|
|
496
497
|
syncStatus("loading");
|
|
498
|
+
const defaults = {
|
|
499
|
+
defer: true,
|
|
500
|
+
fetchpriority: "low"
|
|
501
|
+
};
|
|
502
|
+
if (isAbsolute) {
|
|
503
|
+
defaults.crossorigin = "anonymous";
|
|
504
|
+
defaults.referrerpolicy = "no-referrer";
|
|
505
|
+
}
|
|
497
506
|
script.entry = head.push({
|
|
498
|
-
script: [{
|
|
507
|
+
script: [{ ...defaults, ...input, key }]
|
|
499
508
|
}, options);
|
|
500
509
|
}
|
|
501
510
|
return loadPromise;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unhead",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.5",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Harlan Wilton",
|
|
7
7
|
"email": "harlan@harlanzw.com",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"hookable": "^5.5.3",
|
|
37
|
-
"@unhead/dom": "1.9.
|
|
38
|
-
"@unhead/
|
|
39
|
-
"@unhead/
|
|
37
|
+
"@unhead/dom": "1.9.5",
|
|
38
|
+
"@unhead/shared": "1.9.5",
|
|
39
|
+
"@unhead/schema": "1.9.5"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "unbuild .",
|