Jeff Posnick
Jeff Posnick
CC: @rachelandrew @devnook for visibility.
In an attempt to isolate just the code that might potentially be slow from the larger service worker code, I put together https://gist.github.com/jeffposnick/e0f6a1bc48d66bf118deb908e442188a It's runnable by copying and pasting into...
After poking at this a bit more, I think that some of the overhead is due to https://github.com/chromeos/static-site-scaffold-modules/blob/e1cd1cd0620c64e665a9f64292f58e0b63d80b43/modules/service-worker-includes/index.js#L38 If I change that `[\s\S]*` from the start of that RegExp into...
Switching to `.*` with the `s` flag takes it back to `swiCleanup: 2224.31591796875ms`. At least it's obvious what the expensive bit is now!
I've been looking into the `service-worker-includes` codebase a bit more, and I just wanted to clarify something with @Snugug: Does the `swiCleanup` code just "undo" the `serviceWorkerInclude` code, getting the...
Oh, I think I am misinterpreting something then I was under the impression that the network response would already be "pristine" and could just be used as-is to populate the...
(FWIW, this expensive `RegExp` processing would be a perfect candidate for offloading to a `Worker`, but browsers don't support spinning up a new `Worker` from inside of the `ServiceWorkerGlobalScope`.)
@Snugug, here's a potential refactoring for which I'd appreciate a correctness check. The one breaking change (beyond some minor differences about being more strict about extraneous space characters, which is...
Also, here's a new `gist` with a better test case and comparison of the output of both the original code and this revised code: https://gist.github.com/jeffposnick/fd33ce98a32973b2ca738293744101b6 My original `gist` was processing...
> someone should be able to nest multiple includes; consider a logo being reused in a header and a footer, with all three being includes. The code complexity increases quite...