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 - Dojo
RequireJS - Dojo
Dojo is a JavaScript toolkit which is based on the AMD module architecture that provides additional modules to add extra functionapty to the web apppcation and also saves time and scale in the web apppcation development process.
Example
The following example shows the usage of Dojo along with RequireJS. Create an html file with the name index.html and place the following code in it −
<!DOCTYPE html>
<html>
<head>
<title>RequireJS Dojo</title>
<script data-main="app" src="pb/require.js"></script>
</head>
<body>
<h2>RequireJS Dojo</h2>
<p>
Hello... ...
</p>
</body>
</html>
Create a js file with the name app.js and add the following code in it −
require ({ //You can configure loading modules from the pb directory baseUrl: pb , paths: { //mapping of package dojo: http://sfoster.dojotoolkit.org/dojobox/1.7-branch/dojo } }, [ //modules which we are using here dojo/dom ], function(dom) { //using the byId method from dom module var mydojo = dom.byId( dojo_val ) mydojo.innerHTML = "The text is displaying via dojo/dom"; } );
Output
Open the HTML file in a browser; you will receive the following output −
Advertisements