What is the difference between define and require in RequireJS?

What is the difference between define and require , and when should I use each of them? I read various answers on Stack Overflow, but I still have not been able to understand.

For example, if it was on main.js (points are required in the configuration file), what is the difference?

 define(["jquery"], function($) { do something with $ }); require(["jquery"], function($) { do something with $ }); 

Is $/jQ guaranteed to be loaded and ready in both?

+7
source share
1 answer

They do the same inside. But ...... you must define your entry point for your application with require and define the rest of the modules with define . I find that this makes it possible to understand what role the current module that you are looking at is actually playing in terms of your entire application.

+3
source

All Articles