What is javascript "required"?

I analyzed javascript codes in the chrome extension and noticed this in it.

require("name of required class/file/module") //Not sure whether it is class,file,module 

Maybe this is because I'm new to programming or something like that, but I can't find the β€œrequire” keyword in the link or javascript documentation. The import operation to import modules. I googled for a requirement for javascript, but all I can find is "require" for node.js, server side scripts using javascript. I am talking about the chrome extension / client side of the script. Does anyone have an idea about this?

+6
source share
2 answers

require method is part of the commonjs file and module loader. You can check more details on the Example page.

+3
source

You are probably looking for requirejs .

RequireJS is a downloadable JavaScript file and module. It is optimized for use in a browser, but it can be used in other JavaScript environments such as Rhino and Node. Using a modular script loader, such as RequireJS, will improve the speed and quality of your code.

+2
source

All Articles