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
  • 56,454
  • 22
  • 99
  • 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
  • 56,454
  • 22
  • 99
  • 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
  • 123,782
  • 12
  • 99
  • 138
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,702
  • 3
  • 29
  • 56