minify icon indicating copy to clipboard operation
minify copied to clipboard

strips required ending semi-colon from end, causing errors.

Open slloyd88 opened this issue 4 years ago • 1 comments

With your latest code when I minify the following it strips the semi-colon off the end, causing errors.

Non-minified code:

(function() {
	var test = document.createElement('input');
	function style(element, styles) {
		for (var prop in styles){
	    	element.style.setProperty(prop, styles[prop], 'important');
		}
	}
})();

Minified Code: (function(){var test=document.createElement('input');function style(element,styles){for(var prop in styles){element.style.setProperty(prop,styles[prop],'important')}}})()

slloyd88 avatar Jul 09 '19 01:07 slloyd88

I also have ran into this issue sadly. back-to-top.js:

document.addEventListener('DOMContentLoaded', async () => {
  // ... Some code
});

graphql.js:

class GraphQL {
  // ... Some code
}

Result in the following when minified:

document.addEventListener('DOMContentLoaded', async () => {})class GraphQL{}

Using the following code:

$bundle = '';
for($file as $assetFile) {
  $fileContent = $assetFile->read();  // returns the text content of the JS file
  $minifier = new Minify\JS();
  $minifier->add($fileContent);
  $bundle .= $minifier->minify();
}

// ... Write bundle with minified JS to file 

FinlayDaG33k avatar Apr 18 '21 18:04 FinlayDaG33k