Sea.js Manual & Documentation


Table of Contents


JSON Plugin

With SeaJS, it is easy to load json file.

First, using seajs.config to enable the json plugin by adding it to preload:

seajs.config({
  preload: ['plugin-json']
});

Then, just write your json files, and load them using require:

a.json:

{
  "name": "Frank",
  "age": 30
}

main.js:

define(function(require) {
  var json = require('./a.json');
  // do sth.
});

Except .json extension, you can also use the json! prefix to specify a json resource.

Please see the test cases: test.html