diff --git a/src/compressors/html.ts b/src/compressors/html.ts
index 2892b0b..2915cd0 100644
--- a/src/compressors/html.ts
+++ b/src/compressors/html.ts
@@ -1,6 +1,7 @@
import { minify } from 'html-minifier-terser';
import { compressCSS } from './css.js';
import { compressJS } from './js.js';
+import config from '../config.js';
async function minifyJSinHTML(originalCode: string): Promise {
const newCode = await compressJS(originalCode);
@@ -27,7 +28,7 @@ export async function compressHTML(originalCode: Buffer): Promise {
minifyCSS: minifyCSSinHTML,
minifyJS: minifyJSinHTML,
sortClassName: true,
- sortAttributes: true,
+ sortAttributes: config.html.sort_attributes,
});
if (newhtmlData) return Buffer.from(newhtmlData, 'utf-8');
diff --git a/src/config-default.ts b/src/config-default.ts
index dd5b36d..11c86ce 100644
--- a/src/config-default.ts
+++ b/src/config-default.ts
@@ -3,6 +3,7 @@ import { Options } from './config-types.js';
const default_options: Options = {
html: {
add_css_reset_as: 'inline',
+ sort_attributes: false,
},
css: {
inline_critical_css: false,
diff --git a/src/config-types.ts b/src/config-types.ts
index 894b0b8..6ffa751 100644
--- a/src/config-types.ts
+++ b/src/config-types.ts
@@ -13,6 +13,7 @@ export type Options = {
":where(img){height:auto}"
*/
add_css_reset_as: 'inline' | 'off';
+ sort_attributes: boolean;
};
js: {
compressor: 'esbuild' | 'swc'; // swc have smaller result but can break code (seen with SvelteKit code)