Delay JS exclusions, add: calculation-engine.js fht-eye-decoder so the decoder responds on the first click (not after an interaction). 3. gtag() must already be on the page (it is, via your GT-/G- tag) for the GA4 event to fire. This file is intentionally 100% ASCII. Do not paste translated text in here; edit copy in calculation-engine.js (MASTER_UI) instead.
–>
#fht-eye-decoder{max-width:680px;margin:0 auto;font-size:17px;line-height:1.55}
#fht-eye-decoder h2{margin:0 0 .3em;font-size:1.5em}
#fht-eye-decoder .fed-intro{color:#555;margin:0 0 1em}
#fht-eye-decoder label{display:block;font-weight:600;margin-bottom:6px}
#fht-eye-decoder .fed-inrow{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
#fht-eye-decoder input{font-size:1.1em;padding:10px 12px;border:1px solid #c6ccd2;border-radius:8px;width:160px}
#fht-eye-decoder button{font-size:1.05em;padding:11px 20px;border:0;border-radius:8px;background:#1a73e8;color:#fff;cursor:pointer}
#fht-eye-decoder button:hover{background:#1666d0}
#fht-eye-decoder .fed-hint{font-size:.85em;color:#777;margin-top:8px}
#fht-eye-decoder .fed-result{margin-top:20px;border:1px solid #e3e6ea;border-radius:12px;padding:18px 20px}
#fht-eye-decoder .fed-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:8px}
#fht-eye-decoder .fed-head strong{font-size:1.5em}
#fht-eye-decoder .fed-chip{padding:3px 12px;border-radius:999px;font-size:.82em;font-weight:600}
#fht-eye-decoder .sev-mild{background:#e6f7ec;color:#1c7a3e}
#fht-eye-decoder .sev-moderate{background:#fff4e0;color:#9a5b00}
#fht-eye-decoder .sev-high{background:#fdeaea;color:#b42323}
#fht-eye-decoder .sev-plano{background:#eef0f2;color:#444}
#fht-eye-decoder .fed-desc{margin:.2em 0 1em}
#fht-eye-decoder .fed-row{display:flex;justify-content:space-between;gap:12px;padding:8px 0;border-top:1px solid #eef0f2}
#fht-eye-decoder .fed-k{color:#666}
#fht-eye-decoder .fed-v{font-weight:600;text-align:right}
#fht-eye-decoder .fed-disc{font-size:.83em;color:#777;margin-top:18px}
/* fht-noindex-guard */(function () { if (window.location.search) { var m = document.querySelector(‘meta[name=”robots”]’); if (!m) { m = document.createElement(‘meta’); m.setAttribute(‘name’, ‘robots’); document.head.appendChild(m); } m.setAttribute(‘content’, ‘noindex, nofollow’); }
})();/* fht-eye-decoder */(function () { var BASE = { en: “/eye-prescription-decoder/”, hi: “/hi/eye-prescription-decoder/”, es: “/es/eye-prescription-decoder/” }; function detectLang() { var p = window.location.pathname; if (p.indexOf(“/hi/”) === 0) return “hi”; if (p.indexOf(“/es/”) === 0) return “es”; return “en”; } var L = detectLang(); function $(id) { return document.getElementById(id); } function setText(id, s) { var el = $(id); if (el) { el.textContent = s; } } function getParam(k) { var m = new RegExp(“[?&]” + k + “=([^&]*)”).exec(window.location.search); return m ? decodeURIComponent(m[1]) : null; } function setNoindex() { var m = document.querySelector(‘meta[name=”robots”]’); if (!m) { m = document.createElement(“meta”); m.setAttribute(“name”, “robots”); document.head.appendChild(m); } m.setAttribute(“content”, “noindex, nofollow”); } function row(k, v) { var d = document.createElement(“div”); d.className = “fed-row”; var a = document.createElement(“span”); a.className = “fed-k”; a.textContent = k; var b = document.createElement(“span”); b.className = “fed-v”; b.textContent = v; d.appendChild(a); d.appendChild(b); return d; } function render(r, U) { var box = $(“fed-result”); if (!box) { return; } while (box.firstChild) { box.removeChild(box.firstChild); } var head = document.createElement(“div”); head.className = “fed-head”; var val = document.createElement(“strong”); val.textContent = r.valueLabel; head.appendChild(val); var chip = document.createElement(“span”); chip.className = “fed-chip sev-” + r.severity; chip.textContent = r.severityRange; head.appendChild(chip); box.appendChild(head); var desc = document.createElement(“p”); desc.className = “fed-desc”; desc.textContent = r.description; box.appendChild(desc); box.appendChild(row(U.rType, r.typePlainEnglish)); box.appendChild(row(U.rSeverity, r.severityWord)); box.appendChild(row(U.rSee, r.canSeeClearlyUpTo)); box.appendChild(row(U.rDrive, r.canDriveWithout ? U.yes : U.no)); box.appendChild(row(U.rContact, window.EyeDecoder.formatPower(r.contactLensEquivalent))); if (r.needsGlassesFor && r.needsGlassesFor.length) { box.appendChild(row(U.rNeeds, r.needsGlassesFor.join(“, “))); } box.hidden = false; } function fireGA(r) { if (typeof window.gtag !== “function”) { return; } window.gtag(“event”, “calculator_result”, { tool_name: “eye_prescription_decoder”, input_value: r.valueLabel, result_severity: r.severity, result_type: r.type, language: L, // read BEFORE we pushState below, so a fresh interaction reads empty search session_source: window.location.search ? “direct_link” : “tool_interaction” }); } function run(fromLoad) { var inp = $(“fed-input”); if (!inp) { return; } var raw = (inp.value || “”).replace(“,”, “.”).trim(); var v = parseFloat(raw); if (isNaN(v)) { return; } var ED = window.EyeDecoder; var onGrid = ED.isOnGrid(v); var q = ED.roundQuarter(v); var inRange = (q = -10) || (q >= 0.25 && q parameter URL + noindex if (!fromLoad) { window.history.pushState({}, “”, “?sph=” + encodeURIComponent(r.valueLabel)); } setNoindex(); } // Inject the shared engine at runtime so the page optimiser’s “Delay JS” // (which only rewrites static HTML) cannot defer it. function loadEngine(cb) { if (window.EyeDecoder) { cb(); return; } var s = document.createElement(“script”); s.src = “/wp-content/uploads/tools/assets/calculation-engine.js?ver=1”; s.onload = cb; s.onerror = function () { /* engine failed to load; leave static markup */ }; document.head.appendChild(s); } function init() { if (!window.EyeDecoder || typeof window.decodePrescription !== “function”) { return; // engine not ready } var U = window.EyeDecoder.uiStrings(L); setText(“fed-heading”, U.heading); setText(“fed-intro”, U.intro); setText(“fed-label”, U.label); setText(“fed-btn”, U.button); setText(“fed-hint”, U.hint); setText(“fed-disc”, U.disclaimer); var inp = $(“fed-input”); if (inp) { inp.placeholder = U.placeholder; } var btn = $(“fed-btn”); if (btn) { btn.addEventListener(“click”, function () { run(false); }); } if (inp) { inp.addEventListener(“keydown”, function (e) { if (e.key === “Enter”) { run(false); } }); } // Render-on-load for shared ?sph= links (noindex already set by the guard). var q = getParam(“sph”); if (q !== null) { if (inp) { inp.value = q; } run(true); } } function boot() { loadEngine(function () { init(); }); } if (document.readyState !== “loading”) { boot(); } else { document.addEventListener(“DOMContentLoaded”, boot); }
})();