Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minify my google chrome extension's javascript files

I am finished up with my google chrome extension development. Now its time to deploy on google chrome extension dashboard. But the problem is How do I minify my javascript files (background.js and content.js). I can use online tools available but they do one file at a time and do not consider the dependency on other javascript file.

For example, message passing between background.js and content.js is done by a key value, which tells the other party that what kind of message is this. I am not sure whether chrome itself minifies my javascript file. I little illiterate here. Please help.

like image 358
Savaratkar Avatar asked Mar 02 '15 08:03

Savaratkar


People also ask

How do I minify a file?

Download the files that you want to minify from your website. Save a copy as a backup. Copy the content of the file and paste it to the appropriate minifier tool. Once it's done, paste the code back into the downloaded file and upload it to your website directory.

Should you minify JavaScript?

It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.

What does it mean to minify JavaScript?

Minification, also known as minimization, is the process of removing all unnecessary characters from JavaScript source code without altering its functionality. This includes the removal of whitespace, comments, and semicolons, along with the use of shorter variable names and functions.


1 Answers

Chrome doesn't perform any minification out of the box. Your Chrome extension will load the JavaScript/CSS files as is - minification is completely up to you. Most extensions are left unminified for ease of debugging and for other users to be able to inspect the code. There should be negligible performance gains typically for extensions.

If you do want to minify you can run uglify tasks using grunt or gulp.

like image 175
peterdotjs Avatar answered Sep 19 '22 16:09

peterdotjs