0

I have already a newly created custom jquery plugin, my question is how to minimize its footprint? like from lines of codes into "1 line" only like other jquery plugin author does.

example:

From this:

(function ($) {
    $.fn.cPlugin = function () {
        //lines of codes here
        // another line of codes here
    }
}(jQuery));

Into this:

(function($){$.fn.cPlugin = function(){//lines of codes here and // another line of codes here}}(jQuery));
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
Oliver Jake
  • 44
  • 1
  • 9

3 Answers3

0

You can use any of these :-

http://javascript-minifier.com/

http://www.jsmini.com/

http://jscompress.com/

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
0

The current state-of-the-art Javascript minifiers are

Run your code (once it's all done and ready for production!) through one of those and you should be good to go.

AKX
  • 152,115
  • 15
  • 115
  • 172
0

If you need to do this frequently, you may want a command line application. You can use the Google Closure Compiler for this task.

Command line invocation:

java -jar compiler.jar --js plugin.js --js_output_file plugin.min.js

Output is a file containing:

(function(a){a.fn.cPlugin=function(){}})(jQuery);
azz
  • 5,852
  • 3
  • 30
  • 58