Skip to content

Commit e24b57b

Browse files
committed
perf(beasties): move checks after early return
1 parent d983f1d commit e24b57b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/beasties/src/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ export default class Beasties {
231231
*/
232232
async embedLinkedStylesheet(link: ChildNode, document: HTMLDocument) {
233233
const href = link.getAttribute('href')
234-
let media: string | undefined = link.getAttribute('media')
235-
236-
if (media && !validateMediaQuery(media)) {
237-
media = undefined
238-
}
239-
240-
const preloadMode = this.options.preload
241234

242235
// skip filtered resources, or network resources if no filter is provided
243236
if (!href?.endsWith('.css')) {
@@ -262,6 +255,12 @@ export default class Beasties {
262255
return
263256
}
264257

258+
let media: string | undefined = link.getAttribute('media')
259+
260+
if (media && !validateMediaQuery(media)) {
261+
media = undefined
262+
}
263+
const preloadMode = this.options.preload
265264
// CSS loader is only injected for the first sheet, then this becomes an empty string
266265
let cssLoaderPreamble
267266
= 'function $loadcss(u,m,l){(l=document.createElement(\'link\')).rel=\'stylesheet\';l.href=u;document.head.appendChild(l)}'

0 commit comments

Comments
 (0)