Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

missing : after property id when minifying with yuicompressor

I have to call an external app on my website with:

  const { toggle  } = window.cdn.createAnimation('Ff8rx6E4'); 
  document.querySelector('#btn-mobile-openapp').onclick = toggle;

This works surprisingly ok. But when I am trying to minify the file, it runs a js validity check and I am getting:

missing : after property id

The regular onclick or eventlisteners won’t work here. Any ideas how to correctly define toggle without running into an error?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This looks to me like the minifier isn’t aware of destructuring. Try switching the JavaScript to

  const animation = window.cdn.createAnimation('Ff8rx6E4'); 
  document.querySelector('#btn-mobile-openapp').onclick = animation.toggle;

Or there could be some invisible character in your { toggle }? I can see 2 spaces before the closing }.

Failing that, what are you using to minify?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading