From 4ff790b492ad092cecee13e7a7c7309db298dcc8 Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Mon, 21 Mar 2016 06:04:40 -0700 Subject: [PATCH] Add a performant indexOf escape to extract function When browserify is compiling hundreds of files, this gives a noticeable performance boost. --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 59432f8..157c368 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,9 @@ function cssExtract (bundle, opts) { // extract css from chunks // obj -> str function extract (chunk) { + // Do a performant check before building the ast + if (String(chunk.source).indexOf('insert-css') === -1) return '' + const css = [] const ast = falafel(chunk.source, { ecmaVersion: 6 }, walk) chunk.source = ast.toString()