Add support for loading as AMD module

If an AMD script loader is registered the function will be registered as an AMD module, otherwise it will be registered in the global namespace.