kangax / html-minifier

Javascript-based HTML compressor/minifier (with Node.js support)
http://kangax.github.io/html-minifier/
MIT License
4.94k stars 571 forks source link

Parse Error: Issue with < > symbol in .js javascript file #1144

Closed courtens closed 1 year ago

courtens commented 1 year ago

How would I go about minifying a javascript file which has less than or greater than in the code?

if (tG < 1 && tG !== 0){
  document.getElementById(t+'G'+f).innerHTML = 1;
} else {
  document.getElementById(t+'G'+f).innerHTML = (Math.round(tG * 100) / 100).toFixed(0);
}

This is my current config file:

{
  "caseSensitive": false,                       
  "collapseBooleanAttributes": false,           
  "collapseInlineTagWhitespace": true,          
  "collapseWhitespace": true,                   
  "conservativeCollapse": true,                 
  "continueOnParseError": true,                 
  "customAttrCollapse": "",                 
  "decodeEntities": false,                      
  "html5": false,                               
  "ignoreCustomFragments": [                    
    "<#[\\s\\S]*?#>",                           
    "<%[\\s\\S]*?%>",                           
    "<\\?[\\s\\S]*?\\?>"                        
  ],                                            
  "includeAutoGeneratedTags": true,         
  "keepClosingSlash": true,                     
  "maxLineLength": 0,                           
  "minifyCSS": true,                            
  "minifyJS": true,                         
  "preserveLineBreaks": false,                  
  "preventAttributesEscaping": false,           
  "processConditionalComments": false,          
  "processScripts": [ ],                                            
  "removeAttributeQuotes": false,               
  "removeComments": true,                       
  "removeEmptyAttributes": false,               
  "removeEmptyElements": false,                 
  "removeOptionalTags": false,                  
  "removeRedundantAttributes": false,           
  "removeScriptTypeAttributes": false,          
  "removeStyleLinkTypeAttributes": false,       
  "removeTagWhitespace": false,                 
  "sortAttributes": true,                       
  "sortClassName": true,                        
  "trimCustomFragments": true,                  
  "useShortDoctype": false                      
}
R4356th commented 1 year ago

Duplicate of #1105.

courtens commented 1 year ago

I ended up using npx swc