Syntax Error when using Cache Enabler’s Minify HTML
-
Dear IAWP Team,
I came across a problem with the JS code generated by IAWP. I noticed that when I use the Cache Enabler plugin’s Minify HTML feature (which includes inline scripts), it causes a syntax error in the minimized inline script output by IAWP. I will leave the minification on for now so you can see it on my website.
Before minimizing
<script> (function () { document.addEventListener("DOMContentLoaded", function (e) { if (document.hasOwnProperty("visibilityState") && document.visibilityState === "prerender") { return; } if (navigator.webdriver || /bot|crawler|spider|crawling/i.test(navigator.userAgent)) { return; } let referrer_url = null; if (typeof document.referrer === 'string' && document.referrer.length > 0) { referrer_url = document.referrer; } const params = location.search.slice(1).split('&').reduce((acc, s) => { const [k, v] = s.split('=') return Object.assign(acc, {[k]: v}) }, {}) const url = "https://thetasbih.com/wp-json/iawp/search" const body = { referrer_url, utm_source: params.utm_source, utm_medium: params.utm_medium, utm_campaign: params.utm_campaign, utm_term: params.utm_term, utm_content: params.utm_content, ...{"payload":{"resource":"singular","singular_id":"2","page":1},"signature":"a648366db04bebc8ceff9e132045dfd9"} } const xhr = new XMLHttpRequest() xhr.open("POST", url, true) xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8") xhr.send(JSON.stringify(body)) }) })(); </script>
After minimizing
<script> (function () { document.addEventListener("DOMContentLoaded", function (e) { if (document.hasOwnProperty("visibilityState") && document.visibilityState === "prerender") { return; } if (navigator.webdriver || /bot|crawler|spider|crawling/i.test(navigator.userAgent)) { return; } let referrer_url = null; if (typeof document.referrer === 'string' && document.referrer.length > 0) { referrer_url = document.referrer; } const params = location.search.slice(1).split('&').reduce((acc, s) => { const [k, v] = s.split('=') return Object.assign(acc, {[k]: v}) }, {}) const url = "https://thetasbih.com/wp-json/iawp/search" const body = { referrer_url, utm_source: params.utm_source, utm_medium: params.utm_medium, utm_campaign: params.utm_campaign, utm_term: params.utm_term, utm_content: params.utm_content, ...{"payload":{"resource":"singular","singular_id":"2","page":1},"signature":"a648366db04bebc8ceff9e132045dfd9"} } const xhr = new XMLHttpRequest() xhr.open("POST", url, true) xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8") xhr.send(JSON.stringify(body)) }) })(); </script>
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Syntax Error when using Cache Enabler’s Minify HTML’ is closed to new replies.