Avatar of Manikandan Thiagarajan
Manikandan Thiagarajan
Flag for India asked on

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

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

i want to understand he require.js
JavaScriptAJAX

Avatar of undefined
Last Comment
Göran Andersson

8/22/2022 - Mon
Kent Dyer

Ref.. http://www.w3schools.com/jsref/met_doc_write.asp

document.write("Hello World")

HTH,

Kent
Manikandan Thiagarajan

ASKER
require js concept hello world program
Göran Andersson

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

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Manikandan Thiagarajan

ASKER
cold you please give me the main.js file
Manikandan Thiagarajan

ASKER
i am the new to the require.js

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

and also specify the advantage
Manikandan Thiagarajan

ASKER
can u zip it and send the file
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
StealthyDev

Hey stmani, nothing other than this could help you :)

http://requirejs.org/docs/jquery.html
ASKER CERTIFIED SOLUTION
Göran Andersson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question