https://github.com/hackwaly/define.js
yet another `amd` loader that support `sync' mode specially.
https://github.com/hackwaly/define.js
Last synced: 10 months ago
JSON representation
yet another `amd` loader that support `sync' mode specially.
- Host: GitHub
- URL: https://github.com/hackwaly/define.js
- Owner: hackwaly
- Created: 2013-06-13T07:11:33.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-06-25T10:53:32.000Z (almost 13 years ago)
- Last Synced: 2025-02-09T23:49:39.730Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 259 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
define.js
=========
yet another `amd` loader that support `sync' mode specially.
# Build & Optimze
the difference from other `amd` loader, such as "requirejs" and so on:
* not just concat modules. the result you won't see `define` and `require`, include the define closure of almost all module. the result code will in a big closure.
* you can build a standalone main module script by giving the main module id.
* you can build a main module script with several lazy load modules as your config. the build-chain will analyze the "async require" (`require([],callback)`) and implicit dependencies(who are in main module, who are in other lazy module, and who are in the up closure). then process it smartly. the lazy module use `eval` to load in the up module's closure. just like "google maps" do.
# How To Use
* use `data-base` attribute to set baseUrl. if's bootstrap path by default.
* use `data-sync` attribute to set sync mode. it's `"false"` by default.
* use `data-main` attribute to set main module id. it's required.
in `sync` mode, you can do this.
```html
// you api is ready for use.
my_api.alert('hello define.js');
```
your api
```javascript
var my_api;
define(function (require){
var alert = require('your_library/your_alert');
my_api = {};
my_api.alert = alert;
});
```
your alert
```javascript
define(function (require, exports){
exports.alert = function (msg){
alert(msg);
};
});
```
so, you can simply replace the script tag to switch release version and dev version.
you did't need write `require([...], function (){ ... })` in your html page.