Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

npx terser -c -m -o like_button.min.js -- like_button.js

This will produce a file called like_button.min.js with the minified code in the same directory. If you're typing this often, you can create an npm script to give this command a name.

@VeromcaChang

This comment has been minimized.

Copy link

VeromcaChang commented Jul 6, 2018

Nice suggestion!

@hitendramalviya

This comment has been minimized.

Copy link

hitendramalviya commented Aug 22, 2018

I like your suggestion, I have a doubt what if we have big composed component e.g. big form using various other components imported in it, how it will be used on a other web app?

@uxdesigndev

This comment has been minimized.

Copy link

uxdesigndev commented Sep 3, 2018

Thank you!!

@hinata4zzahra

This comment has been minimized.

Copy link

hinata4zzahra commented Oct 5, 2018

thanks :)

@zbcoder

This comment has been minimized.

Copy link

zbcoder commented Oct 15, 2018

good

@MedinaGitHub

This comment has been minimized.

Copy link

MedinaGitHub commented Oct 22, 2018

thanks :)

@post443

This comment has been minimized.

Copy link

post443 commented Dec 29, 2018

学习了,感谢分享!

@alexvirtualbr

This comment has been minimized.

Copy link

alexvirtualbr commented Feb 18, 2019

amazing!!!

@h4091

This comment has been minimized.

Copy link

h4091 commented Mar 25, 2019

Nice guy

@drakogemini2

This comment has been minimized.

Copy link

drakogemini2 commented Apr 8, 2019

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.