Should I need to minify/uglify my JS files when running my app on devices?

What would be the benefit to minify/uglify the JS with Ionic?
According to me, it only makes sense when dealing with network.
But if the app runs locally on devices…

If this is needed, I thought about moving the standard js folder containing non-minified js outside the www structure.
Then with a gulp task, I would be able to populate this empty js folder with ONLY minified/uglified JS.
So that my build would contain only those files and not the original.
Is this a good practice?

Thanks

1 Like

Yes, it would be a very good practice! And in my opinion it wouldn’t be bad for ionic to implement such a way by default.

Minify your JS because your app package size will be reduced, your users will be thankfull if your app is not taking up 50mb, but 45mb. Many phones don’t have unlimited disk storage, espescially the older devices. Also, your app will download faster while installing. In my opinion those two reasons are enough to make it worth the work!

Minified JS runs faster. Javascript is an in-memory language, basically it loads all your javascript in memory and executes the script. Yes, less white spaces and uglified variables could improve performance (but it’s pretty small and you pobably won’t visually notice). Also, even when the files are “downloaded” from local, the files have to be loaded from disk into memory, which obviously is faster when your files are smaller!

I would absolutely recommend minify and uglify your js :slight_smile:

1 Like

Excellent :slight_smile: Will do it, thanks

Don’t forget to minify your css as well :wink: I don’t think it’ll help in performance but it will help for package size and some loading speed :slight_smile:

1 Like

Uglifying your code will also make it more difficult to decompile.

It is good practice to uglify / minify.

Regards,

1 Like

I would think the ionic build command should be running minification/uglification ?

2 Likes

Looks like it’s being added in 1.3.1 - toward end of Jan hopefully!

Can you please let me know how it uglify or minify ionic project with steps? or if any website or video available for this?