On test.php over root, login authentication is working fine. While i am trying to implement 'Kakao' login/sign-up process in magento2, I have included 'kakao.js' in the respective login page, its loaded but its giving js error in console "Mismatched anonymous define() module: function ()".

here is the sample code through which I am using to include kakao.js over customer_account_login page -

path - app/code/MyCompany/CustomerAttribute/view/frontend/layout/customer_account_login.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
       <script src="MyCompany_CustomerAttribute::js/kakao.js" order = '5000'/>    

I also create a requirejs-config.js file -

path - app/code/MyCompany/CustomerAttribute/view/frontend

var config = {
    map: {
        '*': {
            kakao: 'MyCompany_CustomerAttribute/js/kakao'

kakao.js file included on customer login page by override customer_account_login.xml but its giving js error on console - Uncaught Error: Mismatched anonymous define() module: function......require.js 166 Don't know what i am doing wrong.

I also tried by remove override customer_account_login.xml but than its not loading kakao.js

here is thel url of kakao.js - developers.kakao.com/sdk/js/kakao.min.js

Please help me sort-out this.


This is because you're not loading kakao.js via Require JS, with Magento 2 you should be using Require JS to load any JS. THe old XML method is no longer best practice.

You can see more info on the dev docs: - http://devdocs.magento.com/guides/v2.1/javascript-dev-guide/javascript/js_init.html - http://devdocs.magento.com/guides/v2.1/javascript-dev-guide/javascript/requirejs_concept.html

A quick example JS script

define(['jquery', 'kakao'], function($, kakao) {
    'use strict';

    // Initialise Kakao here

  • Hi Ben, thx for reply. I already have requirejs-config.js at location - app/code/MyCompany/CustomerAttribute/view/frontend you can see in my post. And I run the setup:static-content:deploy after add this but result is same. or you are saying me to remove override customer_account_login.xml and run only with requirejs-config.js .? I did it but through this kakao.js not including in page . – Atul Mar 10 '17 at 12:27
  • I would remove the XML and add it as a dependency via Require, I have updated my answer with an example – Ben Crook Mar 10 '17 at 12:44
  • Thanks Ben, But there are some questions - in which file i need to define it like your way ? in requirejs-config.js ? or in some other file ? and where you write " Initialise Kakao here" what I need to write here 'code of kakao.js' or in short way how to initialize kakao here ? – Atul Mar 15 '17 at 4:06
  • Hi @Atul - The JS in my answer will need to be in a new file, the location of the file depends on the area it affects. If it's for the login area I believe the best place would be app/design/frontend/PartyShowroom/default/Magento_Customer/web//js/your-script.js. You just need to initialise Kakao, having a quick scan of the docs that is Cocoa.init but I may be wrong. – Ben Crook Mar 15 '17 at 9:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.