Skip to content

Commit e53cd36

Browse files
fix: Optimize AxeBuilder memory usage. (#1154)
If `AxeBuilder` is instantiated many times, each instance of the class will store the 250kb axe source string causing performance issues. I looked at `@axe-core/puppeteer` and they follow the pattern in this PR: - https://github.com/bensenescu/axe-core-npm/blob/develop/packages/puppeteer/src/axePuppeteer.ts#L59 - https://github.com/bensenescu/axe-core-npm/blob/develop/packages/puppeteer/src/utils.ts#L34 No QA required Co-authored-by: Ben Senescu <[email protected]>
1 parent 527d4bd commit e53cd36

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/playwright/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class AxeBuilder {
2626
private includes: SerialSelectorList;
2727
private excludes: SerialSelectorList;
2828
private option: RunOptions;
29-
private source: string;
29+
private axeSource: string | undefined;
3030
private legacyMode = false;
3131
private errorUrl: string;
3232

@@ -35,7 +35,7 @@ export default class AxeBuilder {
3535
this.includes = [];
3636
this.excludes = [];
3737
this.option = {};
38-
this.source = axeSource || source;
38+
this.axeSource = axeSource;
3939
this.errorUrl =
4040
'https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/error-handling.md';
4141
}
@@ -210,7 +210,7 @@ export default class AxeBuilder {
210210
*/
211211

212212
private script(): string {
213-
return this.source;
213+
return this.axeSource || source;
214214
}
215215

216216
private async runLegacy(context: SerialContextObject): Promise<AxeResults> {

0 commit comments

Comments
 (0)