For example, I minified the following code but it turns into error:-
Original code:-
echo '<script>(function(w, d){
var b=d.getElementsByTagName("body")[0],s=d.createElement("script");s.async=!0;
s.src = !("IntersectionObserver" in w) ? "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-8.11' . $suffix . '.js" : "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-10.11.1' . $suffix . '.js";
w.lazyLoadOptions = {
elements_selector: "' . esc_attr( implode( ',', $elements ) ) . '",
data_src: "lazy-src",
data_srcset: "lazy-srcset",
data_sizes: "lazy-sizes",
skip_invisible: false,
class_loading: "lazyloading",
class_loaded: "lazyloaded",
threshold: ' . esc_attr( $threshold ) . ',
callback_load: function(element) {
if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
if (element.classList.contains("lazyloaded") ) {
if (typeof window.jQuery != "undefined") {
if (jQuery.fn.fitVids) {
jQuery(element).parent().fitVids();
}
}
}
}
}
};
b.appendChild(s);
}(window, document));
// Listen to the Initialized event
window.addEventListener(\'LazyLoad::Initialized\', function (e) {
// Get the instance and puts it in the lazyLoadInstance variable
var lazyLoadInstance = e.detail.instance;
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
lazyLoadInstance.update();
} );
} );
var b = document.getElementsByTagName("body")[0];
var config = { childList: true, subtree: true };
observer.observe(b, config);
}, false);
</script>';
--------------------------------------------------------------------------------------------------------------------
I have minified it to:
echo '<script>(function(w,d){var b=d.getElementsByTagName("body")[0],s=d.createElement("script");s.async=!0;s.src=!("IntersectionObserver"in w)?"' . ROCKET_LL_FRONT_JS_URL . 'lazyload-8.11' . $suffix . '.js":"' . ROCKET_LL_FRONT_JS_URL . 'lazyload-10.11.1' . $suffix . '.js";w.lazyLoadOptions={elements_selector:"' . esc_attr( implode( ',', $elements ) ) . '",data_src:"lazy-src",data_srcset:"lazy-srcset",data_sizes:"lazy-sizes",skip_invisible:false,class_loading:"lazyloading",class_loaded:"lazyloaded",threshold:" . esc_attr( $threshold ) . ",
callback_load:function(element){if(element.tagName==="IFRAME"&&element.dataset.rocketLazyload=="fitvidscompatible")if(element.classList.contains("lazyloaded"))if(typeof window.jQuery!="undefined")if(jQuery.fn.fitVids)jQuery(element).parent().fitVids()}};b.appendChild(s)})(window,document);
window.addEventListener(\'LazyLoad::Initialized\',function(e){var lazyLoadInstance=e.detail.instance;var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){lazyLoadInstance.update()})});var b=document.getElementsByTagName("body")[0],config={childList:!0,subtree:!0};observer.observe(b,config)},!1);
</script>';