English 中文(简体)
RequireJS - jQuery
  • 时间:2024-09-17

RequireJS - jQuery


Previous Page Next Page  

RequireJS uses jQuery as another dependency and registers as named module jquery in lowercase and by default, also registers itself by using the global functions $ and jQuery while using the AMD/RequireJS.

Loading jQuery

require([ jquery ], function($) {
   //code here
}

You can load multiple and custom pbraries along with the jQuery as shown below −

require([ custom_pbrary_path , jquery ], function(load_pbrary,$) {
   //related code of $ and load_pbrary
});  

The following table shows the use of jQuery with RequireJS for specifying their dependencies.

Sr.No. Types & Description
1 Using Shim Config

jQuery uses shim configuration to define the dependencies for jQuery plugins.

2 Loading jQuery from CDN

jQuery uses CDN to define the dependencies for jQuery plugins.

Advertisements