0

Some reactjs code includes reactJs source inside html file,

<script src="react-0.13.1.js" type="text/javascript"></script>
<script src="JSXTransformer-0.13.1.js"  type="text/javascript"></script>
<script src="app.js"></script>

Some people are using commonJs require syntax in their app.js,

var React = require("React")

Does both the code blocks do the same thing?

How does the browser handle the require function call because mostly servers use require function?

  • possible duplicate of [How to require CommonJS modules in the browser?](http://stackoverflow.com/questions/7576001/how-to-require-commonjs-modules-in-the-browser) – WayneC Apr 30 '15 at 11:37

1 Answers1

0

If you use the CommonJS module system, you need a tool like Browserify or Webpack to analyse your code and see which modules you are requiring. They then take all those modules, and bundle them into one big Javascript file. And since all the code/modules are in the same file at the end, you can require modules in a way which makes it look like it is blocking the UI during the time the module is located, but it's really not.

Anders Ekdahl
  • 22,685
  • 4
  • 70
  • 59