Question

I am trying to add a live chat script to my Magento 2 site. I had previously added slick.js to my Magento 2 site and the require-config.js file looked like this-

var config = {
paths: {
    slick: 'js/slick.min',
},
shim: {
    slick: {
        deps: ['jquery']
    }
}
};

Everything worked. I took the script from the live chat company and placed it in customscript.js in the same folder that slick is in. I changed my require-cinfig.js to-

var config = {
paths: {
    slick: 'js/slick.min',
    slaask: 'js/customscript'
},
shim: {
    slick: {
        deps: ['jquery']
    }
}
};

I have cleared all the static content and the cache. But the live chat box does not display. When I look into my require-config.js linked to from the header it shows-

require.config(config);
})();
(function() {
var config = {
paths: {
    slick: 'js/slick.min',
    slaask: 'js/customscript'
},
shim: {
    slick: {
        deps: ['jquery']
    }
}
};

I have contacted the chat company and the blame Magento. I have contacted Magento and they blame the chat company. How can I get this working?

Edit: Copy of the script

!function(){var x=document.createElement("script");x.src="https://cdn.slaask.com/chat.js",x.type="text/javascript",x.async="true",x.onload=x.onreadystatechange=function(){var x=this.readyState;if(!x||"complete"==x||"loaded"==x)try{

_slaask.init('4942661a635c280f5');

}catch(x){}};var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(x,t)}();
Was it helpful?

Solution

I received this back from the developer of the plugin- Haha yes, actually we were using plugins that were using an incompatible way to use the define function, and the error was triggered at the next define call (from other modules), which explains why it was breaking modules already present on your website.

That has been fixed and now everything works fine. I was able to just paste it in the header.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top