RequireJS Tutorial
RequireJS Useful Resources
Selected Reading
- RequireJS - Plugins
- RequireJS - CommonJS
- RequireJS - Dojo
- RequireJS - NodeJS
- RequireJS - jQuery
- RequireJS - Optimizer
- RequireJS - Defining Function
- RequireJS - AMD Modules
- RequireJS - Configuration
- RequireJS - Environment Setup
- RequireJS - Overview
- RequireJS - Home
RequireJS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
RequireJS - Environment Setup
RequireJS - Environment Setup
In this chapter, we will understand how to set up the environment for RequireJS. For this, you need to download the latest version of RequireJS pbrary. You can download either the
or .After downloading, we need to include the require.js file in your pbs folder and the structure of your project should be as shown below −
projectname/ |--index.html |--pbs/ |---main.js |---require.js |---helper/ |----util.js
We need to define an html file as index.html where RequireJS is loaded as shown below.
<html> <head> <script data-main = "pbs/main" src = "pbs/require.js"></script> </head> <body> <h1> RequireJS Sample Page </h1> </body> </html>
Note that only require.js with a RequireJS call is included in the script tag to load the script.
RequireJS in Node
There are two ways to get the Node adapter.
npm − You can install the latest release of requirejs from the command prompt as shown below.
npm install requirejs
Download r.js − You can download the r.js file from the
page and source from r.js page.