I've added a lot of RequireJS code, but know suddenly it does not work anymore. I get an error 'Mismatched anonymous define()' for code that's added from phtml files. This is the code where the error is thrown:

the code where the error is thrown

This is the error is thrown:


How can this suddenly not work anymore?


I think there's something completely off with my JS loading. I get different JS errors each time I load the page:

enter image description hereenter image description hereenter image description here

Update 2

Thanks to Siarhey Uchukhlebau I found the answer. The real error was thrown by an external script (Tawk.to, a chat client). This error caused all kind of weird errors. I will investigate this problem further to check if we can isolated these kind of script to prevent them from messing with our main script.

  • You can find more info about the "Mismatched anonymous define() modules" error in the requireJS docs – Siarhey Uchukhlebau Jun 2 '17 at 11:41
  • Hi Siarhey, thanks for your comment. I know about this part in the documentation. The weird thing is it worked for a long time, and now it does not work anymore. I've implemented the requirejs functions as shown in the documentation. – Silvan Jun 2 '17 at 11:43
  • Can you share a link to your dev? – Siarhey Uchukhlebau Jun 2 '17 at 11:58

As I can see in the debug error comes from the online chat script:


debug window

First, try to remove it from your store, clean cache and make sure that error has gone, then I'll recommend you contact their support team.

|improve this answer|||||
  • Siarhey, that's awesome. This solved all of the weird JS errors. I have two questions that you maybe can answer: - How can we debug these errors properly? I see you use the sources tab which I'm known with. But the real error is far away. Is there an easy way to debug this? - Is there a way we can prevent these issues from external scripts? Maybe isolate them or something, to prevent messing with our RequireJS. Thanks again! – Silvan Jun 2 '17 at 12:58
  • 1
    @Silvan I just move up on the trace of methods call and come to the source where conditions met (arg[0] is null) , then during inspecting the args I found some info about source class, like specified global variable $_TAWK_. Using google i found script with that variable and found some script on your site: chat widget on your site generates that error. I'll recomend you to start debuging from the line where error was thrown and inspect call-stack trace. PS: Take my apology for my English, i don’t have a good command of it. – Siarhey Uchukhlebau Jun 2 '17 at 13:11

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.