A Super Fast And Light Module Loader implemented CommonJS Modules/AsynchronousDefinition and Modules/LoaderPlugin Specifications.
基于CommonJS Modules/AsynchronousDefinition 和 Modules/LoaderPlugin 规范实现的一个轻量级的高性能模块加载器.
// amd(requirejs) style - amd(requirejs)风格
define(["require", "./dep-a", "./dep-b"], function(depa, depb) {
var sum = depa + depb;
return sum + require("./text!./hello.html");
});
// cjs style - cjs风格
define(function(require, exports, module) {
return require("./lang").indexOf([1, 2, 3], 4) > -1;
});// synax - 语法
require([module-id-1, module-id-2], function(mod1, mod2){
// do something
});
// example - 例子
require(["./lang"], function(lang) {
console.log(lang.indexOf(["a", "b"], "c"));
});// use text plugin to load a file
require(["./text!README.md"], function(txt) {
document.write(txt);
});- build from source
workspace@yourname: git clone https://github.com/yessky/loader.git
workspace@yourname: cd loader
loader@yourname: gulp release
copy dist/k.min.js to your project - 复制dist/k.min.js到你的项目中
-
directly download
clone the source to your local machine. then run `gulp` to run tests and view demos
"kspack": A Builder/Packer/Optimizer for the loader - kspack为k.js量身订做的打包工具
A spa-sample-project using the loader - 查看完整基于loader的单页示例项目
A running proudct based on the loader - 基于该loader的生产项目 咪咕音乐触屏版