# How to fix problem when uglifyjs and jsasync libs in js output

**URL:** https://community.haxe.org/t/how-to-fix-problem-when-uglifyjs-and-jsasync-libs-in-js-output/4053
**Category:** Haxe
**Tags:** haxe-js
**Created:** [September 26, 2023, 7:24pm UTC](https://community.haxe.org/t/how-to-fix-problem-when-uglifyjs-and-jsasync-libs-in-js-output/4053 "2023-09-26T19:24:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MaxiHaxe](https://avatars.discourse-cdn.com/v2/letter/m/5fc32e/32.png) [@MaxiHaxe](https://community.haxe.org/u/MaxiHaxe)
#### Post date: [September 26, 2023, 7:24pm UTC](https://community.haxe.org/t/how-to-fix-problem-when-uglifyjs-and-jsasync-libs-in-js-output/4053/1 "2023-09-26T19:24:09Z")

</div>

Hi,

I use for minifying js [https://lib.haxe.org/p/uglifyjs/](https://lib.haxe.org/p/uglifyjs/) which is pretty good until I used in my JS app [https://lib.haxe.org/p/jsasync/](https://lib.haxe.org/p/jsasync/) library.

At minifying my js output i got this error:

```haxe
Parse error at ../project/main.js:146,34
AsyncAwait.fetchURLAsText = async function(url,data) {
                                  ^
ERROR: Unexpected token: keyword «function», expected: punc «;»
    at JS_Parse_Error.get (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:18:1), <anonymous>:71:23)
    at fatal (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:394:27)
    at run (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:343:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:259:5)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:18:47

```

Code works fine without minifying.

Did you already meet with the same problem and what do you recommend to fix it, please?

---

<div class="post-metadata">

### Author: ![joshtynjala](https://community.haxe.org/user_avatar/community.haxe.org/joshtynjala/32/792_2.png) [@joshtynjala](https://community.haxe.org/u/joshtynjala)
#### Post date: [September 26, 2023, 8:26pm UTC](https://community.haxe.org/t/how-to-fix-problem-when-uglifyjs-and-jsasync-libs-in-js-output/4053/2 "2023-09-26T20:26:22Z")

</div>

UglifyJS used to be pretty popular in the JS ecosystem, but a lot of new JS syntax (such as `async`) is not supported by it. In the JS ecosystem, UglifyJS was forked and became [Terser](https://terser.org).

There isn’t a Haxe library specifically for Terser. However, looking at the README for hx-uglifyjs, I see a section titled _Using Terser as alternative of Uglify_. You should read through that and give it a try. I’m guessing that you’ll have better luck using hx-uglifyjs with Terser.

---

<div class="post-metadata">

### Author: ![MaxiHaxe](https://avatars.discourse-cdn.com/v2/letter/m/5fc32e/32.png) [@MaxiHaxe](https://community.haxe.org/u/MaxiHaxe)
#### Post date: [September 27, 2023, 5:20am UTC](https://community.haxe.org/t/how-to-fix-problem-when-uglifyjs-and-jsasync-libs-in-js-output/4053/3 "2023-09-27T05:20:25Z")

</div>

Thank you for it. I will check it.
