ApoorvSaxena / ApoorvSaxena/lozad.js

Export as named AMD module

Open
#233 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
7.5k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior
When using AMD modules, lozad should be a named AMD module, as one has to interact with it

## Current Behavior

It is an anonymous AMD function

## Possible Solution

```javascript
define('lozad',[], function() {..})
```
instead of

```javascript
define(function() {..})
```

## Steps to Reproduce (for bugs)

## Context

I need to import loadz in another module to initialize it.

Quote from jQuery:

> // Register as a named AMD module, since jQuery can be concatenated with other
> // files that may use define, but not via a proper concatenation script that
> // understands anonymous AMD modules. A named AMD is safest and most robust
> // way to register. Lowercase jquery is used because AMD module names are
> // derived from file names, and jQuery is normally delivered in a lowercase
> // file name. Do this after creating the global so that if an AMD module wants
> // to call noConflict to hide this version of jQuery, it will work.
>
> // Note that for maximum portability, libraries that are not jQuery should
> // declare themselves as anonymous modules, and avoid setting a global if an
> // AMD loader is present. jQuery is a special case. For more information, see
> // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon

## Tested on:

Applies to all AMD environments

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.