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
- Write, paste or upload your jQuery script into the editor
- Choose customization options as per you requirement
- Click Minify jQuery button
- 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
(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
!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
$(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
$(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.
Option | Default | Description |
---|---|---|
ECMAScript Version | ES5 (2009) | Target language level for output compatibility |
Enclose | False | Wrap output in a top-level function closure |
Keep Classnames | False | Preserve class names when mangling identifiers |
Keep Function Names | False | Preserve function names for clearer stack traces |
Bare Returns | True | Allow return statements outside functions in parsing |
HTML5 Comments | True | Preserve HTML5-style comments when parsing |
Shebang | True | Support parsing of shebang lines (#!) in scripts |
Arrow Optimization | False | Convert functions to arrow syntax where safe |
Unsafe Arrows | False | Convert ES5 function expressions into ES6 arrow functions |
Collapse Vars | True | Merge single-use variable definitions to reduce code |
Reduce Vars | True | Optimize repeated variable references by reusing values |
Join Vars | True | Combine consecutive variable declarations into a single statement |
Passes | 1 | Number of times compress optimizations are applied |
Comparisons | True | Simplify comparison expressions for smaller output |
Unsafe Comparisons | False | Allow potentially unsafe optimizations on comparisons |
Conditionals | True | Transform conditional statements for compactness |
Dead Code Removal | True | Strip unreachable code blocks from the bundle |
Unused Removal | True | Remove unused variables and functions |
Directives | True | Apply directives like "use strict" where possible |
Drop Console | False | Remove console statements from the code |
Drop Debugger | True | Remove debugger statements from the code |
Evaluate | True | Compute constant expressions at build time |
Hoist Properties | True | Move static object properties to reduce repeated lookups |
Preserve Infinity | True | Keep literal Infinity instead of replacing with 1/0 |
If Return | True | Optimize if statements followed by return for compactness |
Inline | False | Inline functions where beneficial |
Reduce Functions | False | Optimize repeated function expressions |
Sequences | True | Use sequence expressions to merge statements |
Side Effects | False | Drop expressions without side effects |
Switch Optimizations | True | Optimize switch statements for smaller code |
Typeof Optimizations | True | Optimize typeof expressions when safe |
ASCII Only | False | Escape non-ASCII characters in output |
Beautify | False | Format output code for readability instead of minifying |
Always Braces | False | Force curly braces on blocks for consistent style |
Preserve Comments | None | Keep selected comments such as licensing or banner text |
Banner Comment | Empty | Text 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.