Mismatched anonymous define() module

  • Affected Version
    WoltLab Suite 3.0

    I'm trying to include jBox jQuery plugin with:

    <script src="{@$__wcf->getPath()}js/3rdParty/jBox.min.js"></script>

    in footer.tpl but it will result in an error:

    Uncaught Error: Mismatched anonymous define() module: function (jQuery) {
          return (root.jBox = factory(jQuery));
        at makeError (require.js?v=1502853337:168)
        at intakeDefines (require.js?v=1502853337:1251)
        at require.js?v=1502853337:1449

    Is there any other way how can I include that script?

  • Hi

    try it like this:

    require([ '{@$__wcf->getPath()}js/3rdParty/jBox.min.js' ], function (jBox) {
     // usage of jBox goes here
     new jBox('...');

    The regular loading using the script tag interferes with the require.js module loader. You will need to load the script using require.js. The Callback is called, once the script has successfully been loaded.