Skip to content

Commit e483bcc

Browse files
committed
Add a performant indexOf escape to extract function
When browserify is compiling hundreds of files, this gives a noticeable performance boost.
1 parent c51e66a commit e483bcc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ function cssExtract (bundle, opts) {
4444
// extract css from chunks
4545
// obj -> str
4646
function extract (chunk) {
47+
// Do a performant check so we can abort early if there's nothing to extract
48+
if (String(chunk.source).indexOf('insert-css') === -1) return ''
49+
4750
const css = []
4851
const ast = falafel(chunk.source, { ecmaVersion: 6 }, walk)
4952
chunk.source = ast.toString()

0 commit comments

Comments
 (0)