minify
minify copied to clipboard
strips required ending semi-colon from end, causing errors.
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')}}})()
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