putoutjs / minify

Minify with help of 🐊Putout
MIT License
12 stars 3 forks source link

Better way to compress #10

Closed sirenkovladd closed 8 months ago

sirenkovladd commented 10 months ago
import {minify} from '@putout/minify';
const js = `console.log(x + "g");`
const min = minify(js)
console.log(min)
❯ node tt.js
console.log(`${x}g`);

it seems that if you leave this line as an addition, the result will be smaller

console.log(`${x}g`);
console.log(x+'g');

is it not considered an option to either remove the conversion to template literals, or add a check of the original size?

sirenkovladd commented 10 months ago

But for

const js = `throw new Error('The language "' + r.language + '" has no grammar.');`

it was done differently I think this is a mistake because actually it would be better to use template literals here

coderaiser commented 10 months ago

We can add option to disable such transformation, about second case - it’s hard to implement, but PR’s a welcome

coderaiser commented 10 months ago

Just landed ability to disable apply-template-literals plugin 🎉 . Is it works for you?

sirenkovladd commented 10 months ago

As I understood in these changes, only that you turn off this transformation, without additional checking which of the options will be better

but unfortunately, the problem indicated in the title is not solved

coderaiser commented 10 months ago

There is no place I can add the check right now, but you can add a new rule to minify plugin which will check the size and apply transformation (instead of this one).

coderaiser commented 8 months ago

Closed due to a long time of inactivity 🏝

coderaiser commented 8 months ago

Also this can be implemented using @putout/minify API, you can always run with one set of options, and then use another one and check which is better for you.