1"use strict";(("undefined"==typeof window?self:window).webpackChunkdebugbear_gae=("undefined"==typeof window?self:window).webpackChunkdebugbear_gae||[]).push([[3502],{63510(e,t,i){i.r(t),i.d(t,{MinifyJsTool:()=>o});var r=i(87195),n=i(26080),a=i(74848);async function l(e){return(await(0,n.Zl)(e,{compress:!0,mangle:!0})).code||""}const s=[{title:"What is JavaScript minification?",text:"JavaScript minification means reducing script size by removing whitespace, shortening variable names, and optimizing code. While HTTP compression is applied during transfer, minification changes the actual code that's served to the browser."},{title:"Why minify JavaScript code?",text:"Smaller JavaScript files download and parse faster, resulting in faster page load times and a better user experience."},{title:"How does the JavaScript minifier work?",text:"This tool uses [Terser](https://github.com/terser/terser) to reduce the size of your JavaScript code. Terser parses your code, applies optimizations like dead code elimination and variable name mangling, and outputs the smallest possible equivalent code."},{title:"How do I minify JavaScript in production?",text:"Most build tools handle this automatically. Webpack uses [TerserWebpackPlugin](https://webpack.js.org/plugins/terser-webpack-plugin/) in production mode, and bundlers like Vite and esbuild include minification by default."}];function o(){return(0,a.jsx)(r.E,{title:"Online JavaScript Minifier: Compress JS Code",description:"Paste your JavaScript code below and click 'Minify' to reduce its size.",inputLabel:"Input JavaScript",outputLabel:"Minified Output",ctaTitle:"Minify",breadcrumbTitle:"Minify JavaScript",breadcrumbHref:"/tool/minify-js",transform:l,faqItems:s,language:"javascript",sampleCode:"function calculateTotal(items) {\n let total = 0;\n for (const item of items) {\n total += item.price * item.quantity;\n }\n return total;\n}"})}},87195(e,t,i){i.d(t,{E:()=>S}),i(25440),i(62953);var r=i(94430),n=i(52300),a=i(11178),l=i(41802),s=i(96540),o=i(45230),c=i(99827),u=i(25959),d=i(40256),f=i(15874),m=i(63427),h=i(6585),p=i(36898),b=i(74848);const g=p.EditorView.theme({"&":{fontSize:"14px",border:"1px solid #dee2e6",borderRadius:"0.375rem",height:"100%"},"&.cm-focused":{outline:"none",borderColor:"#86b7fe",boxShadow:"0 0 0 0.25rem rgba(13, 110, 253, 0.25)"},".cm-scroller":{fontFamily:"monospace",overflow:"auto"},".cm-content":{padding:"8px 0"},".cm-gutters":{backgroundColor:"#f8f9fa",borderRight:"1px solid #dee2e6",borderRadius:"0.375rem 0 0 0.375rem"}}),y=p.EditorView.theme({"&":{backgroundColor:"#f8f9fa"},".cm-content":{backgroundColor:"#f8f9fa"}});function x(e){switch(e){case"javascript":return(0,d.Q2)();case"html":return(0,u.html)();case"css":return(0,c.AH)()}}function v(e){let t=e.value,i=e.onChange,r=e.language,n=e.readOnly,a=void 0!==n&&n,l=e.height,c=void 0===l?"300px":l;const u=s.useRef(null),d=s.useRef(null);return s.useEffect(()=>{if(!u.current)return;const e=[(0,p.lineNumbers)(),p.EditorView.lineWrapping,(0,f.syntaxHighlighting)(f.defaultHighlightStyle,{fallback:!0}),x(r),(0,m.highlightSelectionMatches)(),(0,o.history)(),p.keymap.of([...o.defaultKeymap,...m.searchKeymap,...o.historyKeymap]),g];a?(e.push(h.EditorState.readOnly.of(!0)),e.push(y)):i&&e.push(p.EditorView.updateListener.of(e=>{e.docChanged&&i(e.state.doc.toString())}));const n=h.EditorState.create({doc:t,extensions:e}),l=new p.EditorView({state:n,parent:u.current});return d.current=l,()=>{l.destroy()}},[r,a]),s.useEffect(()=>{d.current&&t!==d.current.state.doc.toString()&&d.current.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:t}})},[t]),(0,b.jsx)("div",{ref:u,style:{height:c}})}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,n,a,l,s=[],o=!0,c=!1;try{if(a=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;o=!1}else for(;!(o=(r=a.call(i)).done)&&(s.push(r.value),s.length!==t);o=!0);}catch(e){c=!0,n=e}finally{try{if(!o&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(c)throw n}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return w(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?w(e,t):void 0}}
1(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function S(e){let t=e.title,i=e.description,o=e.inputLabel,c=e.outputLabel,u=e.ctaTitle,d=e.breadcrumbTitle,f=e.breadcrumbHref,m=e.transform,h=e.faqItems,p=e.language,g=e.sampleCode;const y=j(s.useState(""),2),x=y[0],w=y[1],S=j(s.useState(""),2),N=S[0],T=S[1],C=j(s.useState(null),2),J=C[0],M=C[1],E=j(s.useState(!1),2),O=E[0],H=E[1],W=x.length>0&&N.length>0?Math.round(100*(1-N.length/x.length)):null;return(0,b.jsx)(a.K7,{isFullWidthWithoutSidebar:!0,header:(0,b.jsx)(r.V,{breadcrumbs:[{title:"Free Tools",href:"/tools"},{title:d,href:f}]}),children:(0,b.jsxs)("div",{className:"",children:[(0,b.jsx)("h1",{className:"mb-2",style:{fontWeight:500},children:t}),(0,b.jsx)("p",{className:"mb-4 color-coldGrey2",children:i}),(0,b.jsxs)("div",{className:"mb-3",children:[(0,b.jsxs)("div",{className:"d-flex justify-content-between align-items-center mb-1",children:[(0,b.jsx)("label",{className:"form-label fw-bold mb-0",children:o}),(0,b.jsxs)("button",{type:"button",className:"btn btn-link btn-sm p-0",onClick:async()=>{w(g),H(!0),M(null);try{const e=await m(g);T(e)}catch(e){M(e instanceof Error?e.message:"Transformation failed"),T("")}finally{H(!1)}},children:["Try sample ",o.replace("Input ","")]})]}),(0,b.jsx)(v,{value:x,onChange:w,language:p,height:"300px"})]}),(0,b.jsx)("button",{className:"btn btn-primary mb-3 btn-block btn-lg",onClick:async function(){if(!x.trim())return M("Please enter some code"),void T("");H(!0),M(null);try{const e=await m(x);T(e)}catch(e){M(e instanceof Error?e.message:"Transformation failed"),T("")}finally{H(!1)}},disabled:O,children:O?"Processing...":u}),J&&(0,b.jsx)("div",{className:"alert alert-danger mb-3",role:"alert",children:J}),N&&(0,b.jsxs)("div",{className:"mb-3",children:[(0,b.jsxs)("div",{className:"d-flex justify-content-between align-items-center",children:[(0,b.jsx)("label",{htmlFor:"code-output",className:"form-label fw-bold mb-0",children:c}),null!==W&&W>0&&(0,b.jsxs)("span",{children:[(0,l.z3)(x.length)," â ",(0,l.z3)(N.length)," | ",(0,b.jsxs)("strong",{children:["-",(0,l.z3)(x.length-N.length)," â ",W,"% smaller"]})]})]}),(0,b.jsx)("div",{className:"mt-1",children:(0,b.jsx)(v,{value:N,language:p,readOnly:!0,height:"400px"})})]}),h&&(0,b.jsx)(n.$,{items:h}),(0,b.jsx)(k,{currentPath:f})]})})}const N=[{href:"/tool/minify-js",title:"JavaScript Minifier"},{href:"/tool/minify-html",title:"HTML Minifier"},{href:"/tool/minify-css",title:"CSS Minifier"},{href:"/tool/minify-json",title:"JSON Minifier"},{href:"/tool/beautify-js",title:"JavaScript Beautifier"},{href:"/tool/beautify-html",title:"HTML Beautifier"},{href:"/tool/beautify-css",title:"CSS Beautifier"},{href:"/tool/beautify-json",title:"JSON Beautifier"}];function k(e){let t=e.currentPath;const i=N.filter(e=>e.href!==t);return(0,b.jsxs)("div",{className:"mt-5",children:[(0,b.jsx)("h2",{className:"h5 mb-3",children:"Try Our Other Code Formatting Tools"}),(0,b.jsx)("div",{className:"d-flex flex-wrap gap-2",children:i.map(e=>(0,b.jsx)("a",{href:e.href,className:"btn btn-link mr-2 mb-2",style:{border:"1px solid #eee"},children:e.title},e.href))})]})}},52300(e,t,i){i.d(t,{$:()=>a});var r=i(29262),n=i(74848);function a(e){let t=e.items;return t&&0!==t.length?(0,n.jsx)("div",{className:"mt-5",style:{maxWidth:1e3},children:t.map((e,t)=>(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("h2",{className:"h5",children:e.title}),(0,n.jsx)(r.UP,{text:e.text})]},t))}):null}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.