-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs-minifier.html
More file actions
138 lines (133 loc) · 8.25 KB
/
js-minifier.html
File metadata and controls
138 lines (133 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Free JavaScript Minifier — Compress & Obfuscate JS</title>
<meta name="description" content="Minify JavaScript to reduce file size. Remove comments, whitespace, and shorten variable names. Free online JavaScript minifier.">
<link rel="canonical" href="https://www.quicktools.mom/js-minifier.html">
<meta property="og:title" content="">
<meta property="og:description" content="">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.quicktools.mom/js-minifier.html">
<meta name="twitter:card" content="summary">
<link rel="stylesheet" href="style.css">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2658921743607446" crossorigin="anonymous"></script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Why minify JavaScript?","acceptedAnswer":{"@type":"Answer","text":"Minified JS loads faster because it's smaller. Removing comments and whitespace can reduce file sizes by 30-60%. This improves page load times, especially on slower connections, and reduces bandwidth costs."}}]}</script>
</head>
<body>
<div class="page-wrapper">
<header class="site-header"><a href="index.html" class="site-logo"><span class="icon">⚡</span> QuickTools</a><nav class="site-nav"><a href="index.html">All Tools</a></nav></header>
<div class="ad-zone ad-zone-top">Ad Space — 728×90</div>
<div class="tool-header">
<div class="tool-badge">⚡ Developer</div>
<h1>JavaScript Minifier</h1>
<p>Minify JavaScript to reduce file size. Remove comments, whitespace, and optimize code.</p>
</div>
<div class="tool-card">
<label>JavaScript Input</label>
<textarea id="input" class="mono" rows="12" placeholder="Paste your JavaScript here...">;// QuickTools JavaScript Example
function calculateTotal(items) {
// Calculate subtotal from items
let subtotal = 0;
for (let i = 0; i < items.length; i++) {
const item = items[i];
subtotal += item.price * item.quantity;
}
// Apply tax
const taxRate = 0.08;
const tax = subtotal * taxRate;
/* Calculate discount
based on total amount */
let discount = 0;
if (subtotal > 100) {
discount = subtotal * 0.1;
}
return {
subtotal: subtotal,
tax: tax,
discount: discount,
total: subtotal + tax - discount
};
}
// Export for modules
export default calculateTotal;</textarea>
<div class="btn-group">
<button class="btn btn-primary" onclick="minify()">⚡ Minify</button>
<button class="btn btn-secondary" onclick="beautify()">✨ Beautify</button>
</div>
<div class="output-area mt-3">
<span class="output-label">Minified Output</span>
<pre id="output" class="mono" style="white-space:pre-wrap;max-height:400px;overflow-y:auto;"></pre>
<button class="copy-btn" onclick="copyOut()">Copy</button>
</div>
<div class="stats-bar">
<div class="stat-item"><span class="stat-value" id="origSize">0</span><span class="stat-label">Original</span></div>
<div class="stat-item"><span class="stat-value" id="newSize">0</span><span class="stat-label">Minified</span></div>
<div class="stat-item"><span class="stat-value" id="savings">0%</span><span class="stat-label">Savings</span></div>
<div class="stat-item"><span class="stat-value" id="lineCount">0 → 0</span><span class="stat-label">Lines</span></div>
</div>
</div>
<div class="ad-zone">Ad Space — 336×280</div>
<div class="faq-section"><h2>FAQ</h2><div class="faq-item"><h3>Why minify JavaScript?</h3><p>Minified JS loads faster because it's smaller. Removing comments and whitespace can reduce file sizes by 30-60%. This improves page load times, especially on slower connections, and reduces bandwidth costs.</p></div></div>
<div class="tool-card" style="max-width:720px;">
<h2 style="font-size:1rem;margin-bottom:0.75rem;">📖 About JavaScript Minifier</h2>
<p style="font-size:0.85rem;line-height:1.7;color:var(--text-muted);margin-bottom:0.75rem;">JavaScript Minifier is a free, browser-based tool built for developers and engineers working with code daily. Minify JavaScript to reduce file size. Remove comments, whitespace, and shorten variable names. Free online JavaScript minifier. This tool processes everything locally using JavaScript — no data is uploaded to any server, no account is required, and there are no usage limits. Whether you’re working on a quick project or handling sensitive data, your privacy is fully protected. Perfect for quick tasks and professional workflows alike, this tool saves you time by eliminating the need for complex software or manual work. Bookmark this page and use it anytime — it works on desktop, tablet, and mobile devices.</p>
<h3 style="font-size:0.9rem;margin-bottom:0.5rem;">How to Use</h3>
<ol style="font-size:0.85rem;color:var(--text-muted);line-height:1.7;padding-left:1.2rem;">
<li><strong>Enter your data</strong> — Type, paste, or upload your input in the fields above.</li>
<li><strong>Configure options</strong> — Adjust any settings or parameters to match your requirements.</li>
<li><strong>Get instant results</strong> — Output updates automatically in real-time as you type.</li>
<li><strong>Copy or download</strong> — Use the Copy button to grab results, or download if available.</li>
</ol>
</div>
<div class="related-tools"><h2>Related Tools</h2><div class="related-grid">
<a href="css-minifier.html"><span class="tool-icon">🎨</span> CSS Minifier</a>
<a href="json-formatter.html"><span class="tool-icon">{ }</span> JSON Formatter</a>
<a href="regex-tester.html"><span class="tool-icon">⚙️</span> Regex Tester</a>
<a href="base64.html"><span class="tool-icon">🔄</span> Base64 Encoder</a>
</div></div>
<div class="ad-zone ad-zone-bottom">Ad Space — 728×90</div>
<footer class="site-footer"><p>© 2026 QuickTools.</p><div class="footer-links"><a href="index.html">All Tools</a><a href="#">Privacy</a></div></footer>
</div>
<script>
function minify(){
const js=document.getElementById('input').value;
let min=js;
min=min.replace(/\/\/.*$/gm,'');
min=min.replace(/\/\*[\s\S]*?\*\//g,'');
min=min.replace(/\n\s*\n/g,'\n');
min=min.replace(/^\s+/gm,'');
min=min.replace(/\s+$/gm,'');
min=min.replace(/\s*([{}()=+\-*/<>!&|;:,?])\s*/g,'$1');
min=min.replace(/\n/g,'');
min=min.replace(/;}/g,'}');
min=min.trim();
setOutput(js,min);
}
function beautify(){
const js=document.getElementById('input').value;let b=js;let indent=0;let result='';let inStr=false;let strChar='';
for(let i=0;i<b.length;i++){const c=b[i];
if(inStr){result+=c;if(c===strChar&&b[i-1]!=='\\')inStr=false;continue;}
if(c==='"'||c==="'"||c==='`'){inStr=true;strChar=c;result+=c;continue;}
if(c==='{'){result+=c+'\n'+' '.repeat(++indent);continue;}
if(c==='}'){result=result.trimEnd()+'\n'+' '.repeat(--indent)+c+'\n'+' '.repeat(indent);continue;}
if(c===';'){result+=c+'\n'+' '.repeat(indent);continue;}
result+=c;
}
result=result.replace(/\n\s*\n/g,'\n').trim();
setOutput(js,result);
}
function setOutput(orig,result){
document.getElementById('output').textContent=result;
const oB=new Blob([orig]).size,nB=new Blob([result]).size;
document.getElementById('origSize').textContent=oB.toLocaleString()+'B';
document.getElementById('newSize').textContent=nB.toLocaleString()+'B';
document.getElementById('savings').textContent=oB?Math.round((1-nB/oB)*100)+'%':'0%';
document.getElementById('lineCount').textContent=orig.split('\n').length+' → '+result.split('\n').length;
}
function copyOut(){navigator.clipboard.writeText(document.getElementById('output').textContent).then(()=>{const b=document.querySelector('.copy-btn');b.textContent='Copied!';b.classList.add('copied');setTimeout(()=>{b.textContent='Copy';b.classList.remove('copied')},2000)});}
</script>
<script src="ads.js"></script>
</body>
</html>