I would like to add External Library to My Custom Module.

I did below steps.


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <link src="Vendor_Module::js/sweetalert.min.js"/>



 var config = {
 map: {
   '*': {
       sweetalert: 'Vendor_Module/js/sweetalert.min',


** Note:-** JS Added I can see it in the source but there's error in the console too.

Uncaught Error: Mismatched anonymous define() module:


Anything missing ??


I think this is because you're adding a require JS module directly to the page via XML rather than adding it as a dependency.

Try adding this as a dependency in your related JS file:

require(['sweetalert'], function(sweetAlert) {
   ... Your code
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy