Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unneeded mangle on destructed function parameters used as shorthands in the function body #175

Open
tinovyatkin opened this issue Oct 5, 2016 · 0 comments
Projects

Comments

@tinovyatkin
Copy link

Manglifier adds shorter names from destructing parameters (and it's good in most cases), however, it produces bigger code if these destruction parameters are used for shorthand object creation inside function body.
It's easier to show on example

Original source:

link.onload = ({ target: { dataset: { style = 'normal', weight = 400, name = 'Roboto' }, href } }) => {
            const font = new FontFace(name, `url(${href}) format("woff2")`, { style, weight });
            doc.fonts.add(font);
            font.load();
            font.loaded.then(() =>
              doc.documentElement.classList.add(['wf', ...name.toLowerCase().split(' '), 'active'].join('-'))
            );
          };

minifies into:

b.onload=({target:{dataset:{style:d='normal',weight:g=400,name:h='Roboto'},href:c}})=>{const i=new FontFace(h,`url(${c}) format("woff2")`,{style:d,weight:g});a.fonts.add(i),i.load(),i.loaded.then(()=>a.documentElement.classList.add(['wf',...h.toLowerCase().split(' '),'active'].join('-')))}

As you may see style and width from parameters destructions are used only as shorthand properties inside function, so, adding renaming parameters d and g only added 6 bytes to resulted code without any benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Mangler
Mangler feature requests
Development

No branches or pull requests

2 participants