Skip to content

Instantly share code, notes, and snippets.

@NickyBobby
Forked from rrgayhart/require-1511.markdown
Created June 12, 2016 23:00
Show Gist options
  • Save NickyBobby/4f8e83de5c7d706440dc722cbc08453a to your computer and use it in GitHub Desktop.
Save NickyBobby/4f8e83de5c7d706440dc722cbc08453a to your computer and use it in GitHub Desktop.
The Concept of Require

When you start working with WebPack for GameTime, you'll notice that you can't just define a variable in one file and find it in another as easily as you can in Rails.

Read Node.js, Require and Exports and Organize Your Code with RequireJS

Fork this gist and answer the following questions:

  • In the context of Node, what is a module?
  • The code examples from the second blog post look very different from the first. Why?
@NickyBobby
Copy link
Author

  • A module is a function or variable that can be exported outside of the file. You can then require that module from another file.
  • The code examples from the second blog post look very different from the first because they are using RequireJS, which allows you to export modules in a way that's more organized. Then RequireJS takes all the defined modules into one file and minifies it them to optimize performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment