# Ionic JavaScript Obfuscation

**URL:** <https://forum.ionicframework.com/t/ionic-javascript-obfuscation/245278>\
**Category:** Ionic Angular\
**Created:** [November 22, 2024, 3:27pm UTC](https://forum.ionicframework.com/t/ionic-javascript-obfuscation/245278 "2024-11-22T15:27:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KerimM](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KerimM](https://forum.ionicframework.com/u/KerimM)\
**Post date:** [November 22, 2024, 3:27pm UTC](https://forum.ionicframework.com/t/ionic-javascript-obfuscation/245278/1 "2024-11-22T15:27:52Z")

</div>

I have a problem with JavaScript obfuscation in my Ionic 6 - Capacitor 6 - Angular 14 project, I followed the [official guide](https://ionic.io/docs/tutorials/mobile-security/javascript-obfuscation) using javascript-obfuscator and I can see the obfuscated files correctly inside the `www` folder but when I enter the apk the `assets\public\main.js` file is not obfuscated as well as the others.

I have also tried removing the android platform `ionic cap remove android` and adding it back `ionic cap add android`.

---

<div class="post-metadata">

**Author:** ![KerimM](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KerimM](https://forum.ionicframework.com/u/KerimM)\
**Post date:** [November 29, 2024, 4:59pm UTC](https://forum.ionicframework.com/t/ionic-javascript-obfuscation/245278/2 "2024-11-29T16:59:28Z")

</div>

I found the solution, you need to change the line to the scripts section of package.json from:

```
...
  "scripts": {     
    "capacitor:copy:after": "npx javascript-obfuscator www --output www --self-defending true"
  }

```

To

```
    ...
  "scripts": {     
    "ionic:build:after": "npx javascript-obfuscator www --output www --self-defending true"
  }

```
