Javascript minimization without mangling code
When i go to copy my JS into an online minimizer, it mangles my code. By that I mean it rewrites things like variables etc. using short vairables etc. Example below:
ORIGINAL:
document.addEventListener('DOMContentLoaded', function () {
const desiredOptions = {
option1: "250mL",
// option2: "Blue", // for multiple options
};
setTimeout(() => {
Object.entries(desiredOptions).forEach(([optionName, targetText]) => {
const labels = document.querySelectorAll(`.block-swatch__item`);
labels.forEach(label => {
const input = document.getElementById(label.getAttribute('for'));
if (!input || input.name !== optionName) return;
if (label.textContent.trim() === targetText) {
label.click();
// console.log(`Auto-selected ${optionName}: ${targetText}`);
}
});
});
}, 10);
});MINIMIZED ONLINE:
document.addEventListener("DOMContentLoaded",(function(){const t={option1:"250mL"};setTimeout((()=>{Object.entries(t).forEach((([t,e])=>{document.querySelectorAll(".block-swatch__item").forEach((n=>{const o=document.getElementById(n.getAttribute("for"));o&&o.name===t&&n.textContent.trim()===e&&n.click()}))}))}),10)}));