Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dtinianow/169beb576deb6aa07f98c936e5a3f444 to your computer and use it in GitHub Desktop.
Save dtinianow/169beb576deb6aa07f98c936e5a3f444 to your computer and use it in GitHub Desktop.
Length Points Week
20 minutes 10 Week 2

The Concept of Require - Research

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.

Deliverable

  • Read Node.js, Require and Exports and Organize Your Code with RequireJS
  • Fork This Gist
  • Respond in your forked gist with answers to the following questions
    • In the context of Node, what is a module?
      • In Node, a module is a file. Everything written in a module is scoped to that file. For the content of a module to be made available outside of that file, it must be exported. The command to export content from a file is module.exports = 'Object'
    • The code examples from the second blog post look very different from the first. Why?
      • RequireJS is optimizer that takes modules, combines them into one file, and minifies them in order to improve performance. A key difference is that the code in the second example loads all the modules first, which optimizes browser performance. If one were performing an asychronous call using the require statements from the first example, the modules may not load in time. In the second example, we know all dependencies before executing the script.

Additional Resources

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