Solved

could you give me the hello world program for require.js

Posted on 2012-12-21
8
454 Views
Last Modified: 2012-12-26
could you give me the hello world program for require.js

i want to understand he require.js
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 38715112
Ref.. http://www.w3schools.com/jsref/met_doc_write.asp

document.write("Hello World")

HTH,

Kent
0
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 38715135
require js concept hello world program
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 38715368
In your page you include the require script, and specify a main script file to load:

<!DOCTYPE html>
<html>
    <head>
        <title>My Sample Project</title>
        <script data-main="main" src="scripts/require.js"></script>
    </head>
    <body>
        <h1>My Sample Project</h1>
    </body>
</html>

Open in new window

In your main.js file you load other scripts, for example a display.js file:

require(["display"], function(util) {
   sayHello('world');
});

Open in new window

The display.js file containing a function used in the main.js file:

function sayHello(name) {
  alert('Hello ' + name);
}

Open in new window

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 38717939
cold you please give me the main.js file
0
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 38717940
i am the new to the require.js

give me the full helloworld program to understand the require.js

and also specify the advantage
0
 
LVL 9

Author Comment

by:Manikandan Thiagarajan
ID: 38717944
can u zip it and send the file
0
 
LVL 15

Expert Comment

by:StealthyDev
ID: 38719902
Hey stmani, nothing other than this could help you :)

http://requirejs.org/docs/jquery.html
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 38720067
The program is already complete.

Save this as index.html:
<!DOCTYPE html>
<html>
    <head>
        <title>My Sample Project</title>
        <script data-main="main" src="scripts/require.js"></script>
    </head>
    <body>
        <h1>My Sample Project</h1>
    </body>
</html>

Open in new window

Save this as main.js:
require(["display"], function(util) {
   sayHello('world');
});

Open in new window

Save this as display.js:
function sayHello(name) {
  alert('Hello ' + name);
}

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sticking text to shapes in Raphael.js 6 41
Dropdown animation to normal dropdown 6 28
Jquery syntax 12 30
Change variable when you click + or - on another end 2 17
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question