jQuery Minifier & Compressor Online

Use this online jQuery minifier to shrink and optimize jQuery code to decrease the size for production. Type, paste or upload your scripts, choose ECMAScript and jQuery safe options, and run the compressor. The tool reduces bundle size while keeping jQuery behavior intact.

Core Features

  • Minify to remove comments, whitespace, and redundant tokens for jQuery code
  • Compress to drop dead code and unused functions from plugins and app scripts
  • Options to preserve class and function names for runtime checks and stack traces
  • Parse settings that accept shebangs bare returns and HTML5 comments
  • Fine grain compress controls like collapse vars evaluate inline and hoist props
  • Control removal of console and debugger statements with drop console and debugger
  • Runs in the browser so you can minify jQuery without uploading files to a server

How to use this jQuery Minifier

  1. Write, paste or upload your jQuery script into the editor
  2. Choose customization options as per you requirement
  3. Click Minify jQuery button
  4. Preview the result, and download it

Why use a jQuery minifier or compressor

Smaller jQuery bundles load faster and improve page loading time. A jQuery minifier removes non essential characters and shortens identifiers. A compressor goes further by inlining constants removing unreachable code and merging statements.

Use the tool to reduce bandwidth and speed up pages while retaining readable source files in version control for debugging.

When processing jQuery libraries avoid property mangling unless you have a whitelist and a full test suite.

Key differences: original jQuery code vs minified output

  • Original code is readable with comments and full identifiers
  • Minified output removes comments whitespace and shortens names to save bytes
  • Compressed output can inline constants remove unused code and reorganize statements for size

Example 1: Simple jQuery Plugin

Original jQuery

Copy
0.37 KB
(function($){
    $.fn.flashText = function(color, duration) {
        return this.each(function() {
            const el = $(this);
            const original = el.css('color');
            el.css('color', color);
            setTimeout(() => el.css('color', original), duration || 500);
        });
    };
})(jQuery);

Minified jQuery

Copy
0.17 KB
!function(c){c.fn.flashText=function(o,s){return this.each((function(){const t=c(this),n=t.css("color");t.css("color",o),setTimeout((()=>t.css("color",n)),s||500)}))}}(jQuery);

Example 2: Advanced jQuery Script

Formatted jQuery

Copy
1.06 KB
$(document).ready(function() {
    function e(e, t) {
        return e.filter(function() {
            return this.value.match(t)
        })
    }
    $.fn.extend({
        highlight: function() {
            return this.css("background-color", "yellow")
        },
        unhighlight: function() {
            return this.css("background-color", "")
        }
    }), $(".btn").click(function() {
        $(".box").toggleClass("active")
    }), $(".close").click(function() {
        $(".box").removeClass("active")
    }), $(".nav-toggle").click(function() {
        $(".nav").slideToggle()
    }), $("input").focus(function() {
        $(this).highlight()
    }).blur(function() {
        $(this).unhighlight()
    }), $("form").submit(function(e) {
        e.preventDefault();
        var t = $("input[name='email']").val();
        if (!t.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/)) {
            alert("Invalid email");
            return !1
        }
        return !0
    }), $(".accordion > .title").click(function() {
        $(this).next().slideToggle()
    })
});

Minified jQuery

Copy
0.70 KB
$(document).ready((function(){$.fn.extend({highlight:function(){return this.css("background-color","yellow")},unhighlight:function(){return this.css("background-color","")}}),$(".btn").click((function(){$(".box").toggleClass("active")})),$(".close").click((function(){$(".box").removeClass("active")})),$(".nav-toggle").click((function(){$(".nav").slideToggle()})),$("input").focus((function(){$(this).highlight()})).blur((function(){$(this).unhighlight()})),$("form").submit((function(n){return n.preventDefault(),!!$("input[name='email']").val().match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/)||(alert("Invalid email"),!1)})),$(".accordion > .title").click((function(){$(this).next().slideToggle()}))}));

Customization Options

Below are are all the jQuery optimization options available while cmopressing your code.

OptionDefaultDescription
ECMAScript VersionES5 (2009)Target language level for output compatibility
EncloseFalseWrap output in a top-level function closure
Keep ClassnamesFalsePreserve class names when mangling identifiers
Keep Function NamesFalsePreserve function names for clearer stack traces
Bare ReturnsTrueAllow return statements outside functions in parsing
HTML5 CommentsTruePreserve HTML5-style comments when parsing
ShebangTrueSupport parsing of shebang lines (#!) in scripts
Arrow OptimizationFalseConvert functions to arrow syntax where safe
Unsafe ArrowsFalseConvert ES5 function expressions into ES6 arrow functions
Collapse VarsTrueMerge single-use variable definitions to reduce code
Reduce VarsTrueOptimize repeated variable references by reusing values
Join VarsTrueCombine consecutive variable declarations into a single statement
Passes1Number of times compress optimizations are applied
ComparisonsTrueSimplify comparison expressions for smaller output
Unsafe ComparisonsFalseAllow potentially unsafe optimizations on comparisons
ConditionalsTrueTransform conditional statements for compactness
Dead Code RemovalTrueStrip unreachable code blocks from the bundle
Unused RemovalTrueRemove unused variables and functions
DirectivesTrueApply directives like "use strict" where possible
Drop ConsoleFalseRemove console statements from the code
Drop DebuggerTrueRemove debugger statements from the code
EvaluateTrueCompute constant expressions at build time
Hoist PropertiesTrueMove static object properties to reduce repeated lookups
Preserve InfinityTrueKeep literal Infinity instead of replacing with 1/0
If ReturnTrueOptimize if statements followed by return for compactness
InlineFalseInline functions where beneficial
Reduce FunctionsFalseOptimize repeated function expressions
SequencesTrueUse sequence expressions to merge statements
Side EffectsFalseDrop expressions without side effects
Switch OptimizationsTrueOptimize switch statements for smaller code
Typeof OptimizationsTrueOptimize typeof expressions when safe
ASCII OnlyFalseEscape non-ASCII characters in output
BeautifyFalseFormat output code for readability instead of minifying
Always BracesFalseForce curly braces on blocks for consistent style
Preserve CommentsNoneKeep selected comments such as licensing or banner text
Banner CommentEmptyText to prepend to the optimized file for identification

Best Practices For jQuery Minification

  • Keep original code in version control
  • Minify jQuery for production only, keep readable builds for development
  • Generate source maps for easier debugging
  • Test minified output across browsers and devices
  • Review third-party libraries before heavy optimization
  • Automate minification in CI with environment flags
  • Use multiple passes only when necessary

Conclusion

This jQuery minifier and compressor helps you reduce bundle size and improve load time and runtime performance. Choose ECMAScript settings and jQuery safe compress options to match your environment.

Always test the minified output with your jQuery plugins before deploying to production.