question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Error: Mismatched anonymous define() module` on the BBC website

See original GitHub issue

Hi,

We’re trying to use iframe-resizer on an embed on the BBC website. However, it fails with the following errors:

Uncaught ReferenceError: iFrameResize is not defined
Uncaught Error: Mismatched anonymous define() module: function p(){function t(e,n){if(!e.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==e.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+e.tagName+">.");m.call(e,n)}return n(),e(window,"message",a),e(window,"resize",w),function(e,n){switch(typeof n){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(n||"iframe"),function(n){t(n,e)});break;case"object":t(n,e);break;default:throw new TypeError("Unexpected data type ("+typeof n+").")}}}

This error is documented here: http://requirejs.org/docs/errors.html#mismatch.

If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.

I am solving it now by patching the iframeResizer.js code to always export a global, even if the page uses RequireJS modules. I thought it’s something you should be aware of though.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
trackmyappcommented, Oct 10, 2022

@YoranBrondsema or anyone else who understood what was met

I am solving it now by patching the iframeResizer.js code to always export a global, even if the page uses RequireJS modules. I thought it’s something you should be aware of though.

If anyone else gets stuck here, I just replaced define with require and it worked.

  if (typeof define === 'function' && define.amd) {
    require([], factory) //--> this is the line
  } else if (typeof module === 'object' && typeof module.exports === 'object') {
    // Node for browserfy
    module.exports = factory()
  }
0reactions
robtreecommented, Jun 9, 2019

I get this error on https://www.cambridgechorale.org.uk/concerts/the-passing-of-the-year-cambridge because the https://helmtickets.com IFRAME widget is using the plug-in and the site uses require.js.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RequireJS Error: Mismatched Anonymous Define() Module
Templates with scripts that leverage RequireJS code and were working prior to upgrading to 9.0 now show an error in the console of...
Read more >
Mismatched anonymous define() module - Stack Overflow
Another possible solution, in some special cases with anonymous modules is to overwrite the requirejs.onError function in order to prevent the default error...
Read more >
Troubleshooting mismatched anonymous define
(index):10 Uncaught Error: Mismatched anonymous define() module: function(){return wr} http://requirejs.org/docs/errors.html#mismatch at ...
Read more >
Uncaught Error: Mismatched anonymous define() module
Uncaught Error: Mismatched anonymous define() module ... when SCRIPT_DEBUG is false which is correct for production/live website, requirejs is not loaded, ...
Read more >
Uncaught Error: Mismatched anonymous define() module
"define" actually trying to add jquery to you DOM, ... this path = app/code/Sample/Module/view/adminhtml/web/js/restore-order.js where you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found