I'm learning about technologies in Frontend and I'm learning to use Browserify and I came across that they used the ''modular'' definition with Browserify. I hope someone can tell me what modular means and what it is for. Thanks in advance.
I'm learning about technologies in Frontend and I'm learning to use Browserify and I came across that they used the ''modular'' definition with Browserify. I hope someone can tell me what modular means and what it is for. Thanks in advance.
This is quite an abstract question and there is no precise answer in the global javascript scenario. What is or is not a module has at least three interpretations (three and a half counting UMD) but I am going to answer you in a general plane.
When you use a JS library, it may have requirements or dependencies. For example, when you use bootstrap, it depends on jQuery, so it's best to put the jquery script tag before the bootstrap script tag.
Those dependencies can have a very elaborate level of nesting, such that they cannot be resolved by merely ordering the script tags. It can be given, for example, that
That dependency tree is trivial to resolve in Node.js, because everything is on your local system and you load it when you build the app. In the browser, instead, you have to choose between:
Browserify complies with the third option. Concatenate in a single file all the dependencies of what you want to use, knowing only the last part. Given that the library you want to use declares its dependencies
And your dependencies declare your dependencies, and so on, browserify takes care of building a module that includes all the nested requirements of the final library you want to use.
Browserify rose to fame about 5 years ago and is still ultra popular, but today there are other libraries (Webpack, JSPM) that do a similar job solving the problem with browserify , which is that two browserified libraries can have a common dependency (for example jQuery) and each one comes with jQuery as a gift, attached.