The difference between Sea.js and require.js

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.