Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For anyone facing the error : Multiple anonymous defines encountered #283

Closed
NotSqrt opened this issue Feb 25, 2015 · 1 comment
Closed

Comments

@NotSqrt
Copy link

NotSqrt commented Feb 25, 2015

My pages have been facing "Multiple anonymous defines encountered" irregularly for some time, and I have finally understood why :

I have set up a minimalistic page to demonstrate the error : http://jsbin.com/suhehuwita/1/
This page triggers the error very reliably, but in a real world web page with more modules, it would happen randomly.

Basically, if an AMD-compatible module is loaded after curl, outside a call to curl(), the error will be triggered.

What you should not do:

<html>
    <head>
        <script type="text/javascript">
            curl = {/* curl config */};
        </script>
        <script src="/curl.js"></script>
        <script src="/some-amd-module.js"></script> <!-- after curl -->
    </head>
    <body>
        <script type="text/javascript">
            curl("same-amd-module", function () {});
        </script>
    </body>
</html>

What you should do instead:

<html>
    <head>
        <script type="text/javascript">
            curl = {/* curl config */};
        </script>
        <script src="/some-amd-module.js"></script> <!-- before curl -->
        <script src="/curl.js"></script>
    </head>
    <body>
        <script type="text/javascript">
            curl("same-amd-module", function () {});
        </script>
    </body>
</html>
@unscriptable
Copy link
Member

Thanks @NotSqrt! This is a common problem encountered by people mixing AMD loaders and <script> elements that might load AMD modules. I'm glad you figured it out and left a solution for others! -- J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants