Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions lib/harAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class HarAnalyzer {
const libFolder = fileURLToPath(new URL('..', import.meta.url));
this.pluginFolder = path.resolve(libFolder, '..');
}
transform2SimplifiedData(harData, url, group) {
transform2SimplifiedData(harData, url) {
const data = {
'url': url,
'security-rules': this.configSecurity,
Expand Down Expand Up @@ -82,20 +82,6 @@ export class HarAnalyzer {
data['script-elements'].push(styleElementObj);
}
});

// Extract style="" attributes from HTML content
// const elementsWithStyleAttr = dom.window.document.querySelectorAll('[style]');
// elementsWithStyleAttr.forEach((element, index) => {
// const styleAttrContent = element.getAttribute('style');
// const styleAttrObj = {
// 'url': htmlObj.url,
// // Wrap the style attribute content in a dummy #id rule
// 'content': `#dummy-style-attribute-id { ${styleAttrContent} }`,
// 'index': htmlObj.index
// };
// data['all-styles'].push(styleAttrObj);
// data['style-attributes'].push(styleAttrObj);
// });
}

return data;
Expand Down Expand Up @@ -175,7 +161,7 @@ export class HarAnalyzer {
this.groups[group] = {};
}

const analyzedData = this.transform2SimplifiedData(harData, url, group);
const analyzedData = this.transform2SimplifiedData(harData, url);
if (!('analyzedData' in this.groups[group])) {
this.groups[group]['analyzedData'] = []
}
Expand Down
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class JavascriptPlugin extends SitespeedioPlugin {
this.harAnalyzer = new HarAnalyzer();
const libFolder = fileURLToPath(new URL('..', import.meta.url));
this.pluginFolder = path.resolve(libFolder);
this.options = options;

this.pug = await fsp.readFile(
path.resolve(this.pluginFolder, 'pug', 'index.pug'),
Expand Down Expand Up @@ -83,7 +84,7 @@ export default class JavascriptPlugin extends SitespeedioPlugin {
}
}
}
close(options, errors) {
// Cleanup if necessary
}
// close(options, errors) {
// // Cleanup if necessary
// }
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
"eslint-config-prettier": "10.1.1",
"eslint-plugin-prettier": "5.2.5",
"eslint-plugin-unicorn": "58.0.0",
"prettier": "3.5.3"
"prettier": "3.5.3",
"serve": "14.2.4",
"serve-handler": "6.1.6",
"typescript": "5.7.2"
},
"dependencies": {
"jsdom": "26.0.0",
Expand All @@ -55,6 +58,8 @@
},
"scripts": {
"test": "ava",
"start-server": "serve test/data/",
"stop-server": "sudo pkill serve",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
Expand Down
Loading