Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the smallest AMD loader to date? [closed]

Tags:

amd

js-amd

loader

I am searching for an AMD loader that supports dynamic code loading, and that is very small.

The loader is to be used in a mobile/high latency environment, and the size of requirejs simply is too much.

I do NOT need:
-text plugins
-css plugins
-i18n plugins

What is the smallest AMD loader that supports these features? I'm looking for something that ideally is no larger than 5k when minified. Gzip is not to be included in this measure.

like image 387
duck degen Avatar asked Jan 15 '13 13:01

duck degen


People also ask

What is AMD format?

Asynchronous module definition (AMD) is a specification for the programming language JavaScript. It defines an application programming interface (API) that defines code modules and their dependencies, and loads them asynchronously if desired.

What is CommonJS and AMD?

AMD and CommonJS are both Javascript module loader. They accomplish the same task but works different. AMD is better for browser, hence, the name 'Asynchronous', as it loads each distinct module in async manner instead of loading in one large file. No extra steps are required to use AMD, it works out-of-the-box.

What is AMD require?

Advertisements. A module in RequireJS is a scoped object and is not available in the global namespace. Hence, global namespace will not be polluted. RequireJS syntax allows to load modules faster without worrying about keeping track of the order of dependencies.


2 Answers

By "dynamic code loading," do you mean something like this?

You may want to try (listed in order of size):

  • amdlite, 1.924 kb minified
  • tinyamd, 2.628 kb minified
  • tAMD, 4.554 kb minified

Full disclosure: I wrote amdlite. It passes all relevant unit tests, but has not seen much real-world use. If you try it and discover anything wrong with it, please file an issue.

like image 93
Dagg Nabbit Avatar answered Sep 30 '22 07:09

Dagg Nabbit


I believe this is reasonably close to the AMD spec, and at 960 bytes minified (not counting the spurious newline at the end) might grab the top spot.

https://github.com/MaxMotovilov/eeMD

like image 36
Max Motovilov Avatar answered Sep 30 '22 05:09

Max Motovilov