With the introduction of the ES6 standard module will gradually exit the historical stage
First, the difference in principle
Sea.js follows the CMD specification. The writing style is similar to node. JS's writing template code. Automatic loading of dependencies, simple and clear configuration. It's just lazy loading.
Require.js follow amd specs, CMD and AMD are basically the same, the biggest difference is that cmd is lazy to load, AMD is preloaded .
Simply put, sea.js belongs to lazy loading, require.js belongs to preload.
Here, by the way, extend the pros and cons of preloading and lazy loading
Preload: Loads all files when first accessed
Advantage: Once the first visit is completed, the speed of the visit will be fast
Cons: The first time you load a page waits a long time.
Lazy loading: The corresponding files are loaded when they are used.
Advantage: The first access speed is relatively fast.
Disadvantage: The speed of accessing other new modules becomes slower.
Write the distinction above:
is to use define to define a template. The function is transferred by the require,exports,module of three parameters.
Basically their usage is very much the same. But the big difference of two points is that you need to pay attention to:
1) sea.js Use the module with the method Seajs.use, and require.js directly with the require keyword
2) sea.js only one module can be passed in only one string, but require must be an array to pass in.
The difference between Sea.js and require.js