Title: Syntax Error when using Cache Enabler&#8217;s Minify HTML
Last modified: March 23, 2023

---

# Syntax Error when using Cache Enabler’s Minify HTML

 *  Resolved [Muslim](https://wordpress.org/support/users/immuslim/)
 * (@immuslim)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/syntax-error-when-using-cache-enablers-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**
 *     ```wp-block-code
       <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**
 *     ```wp-block-code
       <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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsyntax-error-when-using-cache-enablers-minify-html%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Ben Sibley](https://wordpress.org/support/users/bensibley/)
 * (@bensibley)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/syntax-error-when-using-cache-enablers-minify-html/#post-16588314)
 * Thanks for bringing this to our attention.
 * Minification shouldn’t make material changes to the code like this, so I will
   get it in touch with the Cache Enabler devs to see if they can fix this.
 * In the meantime, it looks like there is an option to ignore inline CSS and JS
   when minifying the HTML, so that’s what I would recommend.
 *  Thread Starter [Muslim](https://wordpress.org/support/users/immuslim/)
 * (@immuslim)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/syntax-error-when-using-cache-enablers-minify-html/#post-16590015)
 * Thank you for your prompt response and recommendation. I appreciate you investigating
   the issue and reaching out to the developers of the other plugin for a possible
   solution.
 * I find your plugin to be very impressive and am actually considering replacing
   GA with it. If I encounter any further issues or concerns, I won’t hesitate to
   contact you. Once again, thank you for your assistance.
 *  Plugin Author [Ben Sibley](https://wordpress.org/support/users/bensibley/)
 * (@bensibley)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/syntax-error-when-using-cache-enablers-minify-html/#post-16591720)
 * You’re welcome! And yes, feel free to post here if you need anything else.

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.

 * ![](https://ps.w.org/independent-analytics/assets/icon.svg?rev=3504049)
 * [Independent Analytics - WordPress Analytics Plugin](https://wordpress.org/plugins/independent-analytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/independent-analytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/independent-analytics/)
 * [Active Topics](https://wordpress.org/support/plugin/independent-analytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/independent-analytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/independent-analytics/reviews/)

## Tags

 * [JS Minify](https://wordpress.org/support/topic-tag/js-minify/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ben Sibley](https://wordpress.org/support/users/bensibley/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/syntax-error-when-using-cache-enablers-minify-html/#post-16591720)
 * Status: resolved