Skip to content

Commit 60310ab

Browse files
committed
fix: improve performance by loading sax-wasm only once
1 parent db03f69 commit 60310ab

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.changeset/popular-llamas-fly.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rocket/cli': patch
3+
'@rocket/eleventy-rocket-nav': patch
4+
---
5+
6+
Improve performance by initializing sax-wasm only once even when it is running in parallel

packages/cli/src/eleventy-plugins/insertResponsiveImages.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ async function insertResponsiveImages(html) {
243243
const config = getComputedConfig();
244244

245245
if (!isSetup) {
246-
await parser.prepareWasm(saxWasmBuffer);
247-
isSetup = true;
246+
isSetup = parser.prepareWasm(saxWasmBuffer);
248247
}
248+
await isSetup;
249249

250250
const options = {
251251
inputPath: this.inputPath,

packages/eleventy-rocket-nav/src/addPageAnchors.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,17 @@ function getHeadingsOfHtml(html) {
9797
return { headings, insertPoint };
9898
}
9999

100+
/** @type {boolean | Promise<unknown>} */
100101
let isSetup = false;
101102

102103
/**
103104
* @param {string} content
104105
*/
105106
async function addPageAnchors(content) {
106107
if (!isSetup) {
107-
await parser.prepareWasm(saxWasmBuffer);
108-
isSetup = true;
108+
isSetup = parser.prepareWasm(saxWasmBuffer);
109109
}
110+
await isSetup;
110111

111112
const { headings, insertPoint } = getHeadingsOfHtml(content);
112113
const pageAnchorsHtml = [];

0 commit comments

Comments
 (0)