Usage with UMD

Did you install the Autheos embed code using our CDN but get an error that looks like Autheos is not defined? This may happen because you are using a UMD compatible module loader. As the CDN version of the embed code is exported using the UMD pattern, you’ll want to use your module loader to load the embed code.

UMD, short for Universal Module Definition, is a pattern to load libraries into your application without polluting the global scope. A module loader is then used to load libraries into your application.

Common examples of module loaders are RequireJS and Dojo. If you are using a module loader, you will have to load our embed code through the require function of your module loader.

By default, most module loaders do not look for libraries on a CDN. You’ll need to configure your module loader to understand where the Autheos embed code is located. For example, with RequireJS:

require.config({
  paths: {
    'autheos-embedcode': 'https://cdn.autheos.com//embedcode/latest/embedcode.min.js'
  }
});

require('autheos-embedcode', function (Autheos) {
  Autheos.button(...);
});

Alternatively, you could load the embed code before you load a module loader:

<script src="https://cdn.autheos.com//embedcode/latest/embedcode.min.js"></script>
<script src="/path/to/module/loader.js"></script>

However, since you’re using a module loader already, you may want to consider using npm instead. RequireJS provides r.js to make this process easy.

For more info:

Can I also just download the embed code?#

Of course! If you download the embed code and place it into the base path of your module loader it will work without having to configure your module loader.

However, keep in mind that for every upgrade of the embed code you will be responsible of updating the file you downloaded. If using our CDN, all you would have to do is update the version number.