Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

critters

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

critters - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

30

dist/critters.js

@@ -1201,3 +1201,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

if (this.urlFilter ? this.urlFilter(href) : !(href != null && href.endsWith('.css'))) {
return Promise.resolve();
return undefined;
}

@@ -1230,7 +1230,6 @@

let noscriptFallback = false;
let updateLinkToPreload = false;
if (preloadMode === 'body') {
document.body.appendChild(link);
} else {
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'style');
if (preloadMode === 'js' || preloadMode === 'js-lazy') {

@@ -1247,6 +1246,5 @@ const script = document.createElement('script');

noscriptFallback = true;
updateLinkToPreload = true;
} else if (preloadMode === 'media') {
// @see https://github.com/filamentgroup/loadCSS/blob/af1106cfe0bf70147e22185afa7ead96c01dec48/src/loadCSS.js#L26
link.setAttribute('rel', 'stylesheet');
link.removeAttribute('as');
link.setAttribute('media', 'print');

@@ -1265,8 +1263,8 @@ link.setAttribute('onload', `this.media='${media || 'all'}'`);

} else {
const bodyLink = document.createElement('link');
bodyLink.setAttribute('rel', 'stylesheet');
if (media) bodyLink.setAttribute('media', media);
bodyLink.setAttribute('href', href);
const bodyLink = link.cloneNode(false);
// If an ID is present, remove it to avoid collisions.
bodyLink.removeAttribute('id');
document.body.appendChild(bodyLink);
style.$$links.push(bodyLink);
updateLinkToPreload = true;
}

@@ -1278,6 +1276,5 @@ }

const noscript = document.createElement('noscript');
const noscriptLink = document.createElement('link');
noscriptLink.setAttribute('rel', 'stylesheet');
noscriptLink.setAttribute('href', href);
if (media) noscriptLink.setAttribute('media', media);
const noscriptLink = link.cloneNode(false);
// If an ID is present, remove it to avoid collisions.
noscriptLink.removeAttribute('id');
noscript.appendChild(noscriptLink);

@@ -1287,2 +1284,7 @@ link.parentNode.insertBefore(noscript, link.nextSibling);

}
if (updateLinkToPreload) {
// Switch the current link tag to preload
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'style');
}
}

@@ -1289,0 +1291,0 @@

{
"name": "critters",
"version": "0.0.22",
"version": "0.0.23",
"description": "Inline critical CSS and lazy-load the rest.",

@@ -5,0 +5,0 @@ "main": "dist/critters.js",

@@ -27,3 +27,3 @@ /**

walkStyleRules,
walkStyleRulesWithReverseMirror,
walkStyleRulesWithReverseMirror
} from './css';

@@ -329,3 +329,3 @@ import { createLogger, isSubpath } from './util';

if (this.urlFilter ? this.urlFilter(href) : !href?.endsWith('.css')) {
return Promise.resolve();
return undefined;
}

@@ -366,2 +366,3 @@

let noscriptFallback = false;
let updateLinkToPreload = false;

@@ -371,4 +372,2 @@ if (preloadMode === 'body') {

} else {
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'style');
if (preloadMode === 'js' || preloadMode === 'js-lazy') {

@@ -385,6 +384,5 @@ const script = document.createElement('script');

noscriptFallback = true;
updateLinkToPreload = true;
} else if (preloadMode === 'media') {
// @see https://github.com/filamentgroup/loadCSS/blob/af1106cfe0bf70147e22185afa7ead96c01dec48/src/loadCSS.js#L26
link.setAttribute('rel', 'stylesheet');
link.removeAttribute('as');
link.setAttribute('media', 'print');

@@ -403,8 +401,9 @@ link.setAttribute('onload', `this.media='${media || 'all'}'`);

} else {
const bodyLink = document.createElement('link');
bodyLink.setAttribute('rel', 'stylesheet');
if (media) bodyLink.setAttribute('media', media);
bodyLink.setAttribute('href', href);
const bodyLink = link.cloneNode(false);
// If an ID is present, remove it to avoid collisions.
bodyLink.removeAttribute('id');
document.body.appendChild(bodyLink);
style.$$links.push(bodyLink);
updateLinkToPreload = true;
}

@@ -420,6 +419,5 @@ }

const noscript = document.createElement('noscript');
const noscriptLink = document.createElement('link');
noscriptLink.setAttribute('rel', 'stylesheet');
noscriptLink.setAttribute('href', href);
if (media) noscriptLink.setAttribute('media', media);
const noscriptLink = link.cloneNode(false);
// If an ID is present, remove it to avoid collisions.
noscriptLink.removeAttribute('id');
noscript.appendChild(noscriptLink);

@@ -429,2 +427,8 @@ link.parentNode.insertBefore(noscript, link.nextSibling);

}
if (updateLinkToPreload) {
// Switch the current link tag to preload
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'style');
}
}

@@ -431,0 +435,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc