# Compress app.bundle.js (typesript)

**URL:** <https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227>\
**Category:** ionic-v3\
**Created:** [March 12, 2016, 11:26am UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227 "2016-03-12T11:26:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![BojDom](https://avatars.discourse-cdn.com/v4/letter/b/a9a28c/32.png) [@BojDom](https://forum.ionicframework.com/u/BojDom)\
**Post date:** [March 12, 2016, 11:26am UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/1 "2016-03-12T11:26:56Z")

</div>

Hi , i recently start using ionic2 and im testing it, im really new also with typescript and i don’t know how to use webpack …  
after everyu build i see that ionic generate the file app.bundle.js but it contains comments, whitespaces of angular2 and it’s size is pointless… there is a way to compress it?

---

<div class="post-metadata">

**Author:** ![xr0master](https://avatars.discourse-cdn.com/v4/letter/x/b4bc9f/32.png) [@xr0master](https://forum.ionicframework.com/u/xr0master)\
**Post date:** [March 12, 2016, 11:45am UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/2 "2016-03-12T11:45:54Z")

</div>

You need add uglifyjs to gulp task. Google it 😉

---

<div class="post-metadata">

**Author:** ![dugwood](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dugwood](https://forum.ionicframework.com/u/dugwood)\
**Post date:** [April 19, 2016, 9:07pm UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/3 "2016-04-19T21:07:14Z")

</div>

This should be part of the default process, at least for the production release.

---

<div class="post-metadata">

**Author:** ![dugwood](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dugwood](https://forum.ionicframework.com/u/dugwood)\
**Post date:** [April 19, 2016, 9:37pm UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/4 "2016-04-19T21:37:40Z")

</div>

Tried to add `.pipe(uglify())` in the ionic-gulp-browserify-typescript script by it just hangs. Seems to need some Javascript fixing before…

---

<div class="post-metadata">

**Author:** ![allpref](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/allpref/32/99763_2.png) [@allpref](https://forum.ionicframework.com/u/allpref)\
**Post date:** [April 19, 2016, 9:52pm UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/5 "2016-04-19T21:52:12Z")

</div>

I not tested with Ionic yet, but with pure javascript I use Obfuscator a lot to leave a dirty code.

> **[devunion/gulp-js-obfuscator](https://github.com/devunion/gulp-js-obfuscator)**
>
> gulp-js-obfuscator - Gulp plugin for js-obfuscator.

---

<div class="post-metadata">

**Author:** ![iignatov](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iignatov/32/100112_2.png) [@iignatov](https://forum.ionicframework.com/u/iignatov)\
**Post date:** [April 19, 2016, 10:10pm UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/6 "2016-04-19T22:10:14Z")

</div>

@dugwood Check out [the following post](https://forum.ionicframework.com/t/ionic-2-app-bundle-js-minification/49599/13) for a example how to achieve it using `gulpfile.js`. And it’s on the roadmap - here’s the [issue on Github](https://github.com/driftyco/ionic-cli/issues/752). I guess that it’ll soon become part of the build process for production releases.

---

<div class="post-metadata">

**Author:** ![dugwood](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dugwood](https://forum.ionicframework.com/u/dugwood)\
**Post date:** [April 19, 2016, 10:27pm UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/7 "2016-04-19T22:27:01Z")

</div>

Sorry, didn’t look for the issue on Github, I thought it was the only topic about it, my bad.

I’ve tried a similar approach to yours (changed directly the main module for testing purposes). But I have the same issue as in [Ionic 2 - app.bundle.js - Minification](https://forum.ionicframework.com/t/ionic-2-app-bundle-js-minification/49599/5)

Anyway, I’ll wait for it to be fixed, thanks for the heads up 🙂

@allpref: I’ve tried YUI compressor, which works great on all my javascript files, but it hanged on app.bundle.js too. That how I found this thread.

---

<div class="post-metadata">

**Author:** ![iignatov](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/iignatov/32/100112_2.png) [@iignatov](https://forum.ionicframework.com/u/iignatov)\
**Post date:** [May 3, 2016, 11:28am UTC](https://forum.ionicframework.com/t/compress-app-bundle-js-typesript/46227/8 "2016-05-03T11:28:42Z")

</div>

**UPDATE:** The minification is now part of the standard build process for [TypeScript](https://github.com/driftyco/ionic-gulp-tasks/tree/master/browserify-typescript) and [JavaScript](https://github.com/driftyco/ionic-gulp-tasks/tree/master/browserify-es2015).

There’s an example in [the linked post](https://forum.ionicframework.com/t/ionic-2-app-bundle-js-minification/49599/14) on how to enable it:

> [@Ionic 2 - app.bundle.js - Minification](https://forum.ionicframework.com/t/ionic-2-app-bundle-js-minification/49599/14):
>
> `buildBrowserify` has built-in support for `uglify`…you can activate it by adding `minify` and `uglifyOptions` to the `buildBrowserify` options in `gulpfile.js`.

Besides updating to the latest version of `ionic-gulp-tasks` don’t forget to also update your `gulpfile.js` accordingly using the one in `ionic2-app-base` as template _([TypeScript](https://github.com/driftyco/ionic2-app-base/blob/typescript/gulpfile.js) or [JavaScript](https://github.com/driftyco/ionic2-app-base/blob/master/gulpfile.js))_.
