This repository was archived by the owner on Dec 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,13 +12,13 @@ <h1>JavaScript Module Loading using Require.js</h1>
1212 < p class ="lead "> How to run this example.</ p >
1313
1414 < ol >
15- < li > Open Example-1 .html in browser using any HTTP-SERVER.</ li >
15+ < li > Open Example-2 .html in browser using any HTTP-SERVER.</ li >
1616 < li > Press F12, go to console tab.</ li >
1717 < li > See the message get displayed on that console tab.</ li >
1818 </ ol >
1919
20- < script type ="text/javascript " src ="app/module1.js "> </ script >
21- < script type ="text/javascript " src ="app/module2.js "> </ script >
20+ < script type ="text/javascript " src ="app/module1.js " async =" true " > </ script >
21+ < script type ="text/javascript " src ="app/module2.js " async =" true " > </ script >
2222 < script type ="text/javascript " src ="app/print.js "> </ script >
2323 < script type ="text/javascript " src ="app/init.js "> </ script >
2424 </ body >
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ <h1>JavaScript Module Loading using Require.js</h1>
1717 < li > See the message get displayed on that console tab.</ li >
1818 </ ol >
1919
20+ <!--
21+ Specifing single entry point to our application;
22+ Loading require.js as the first script dependency file with configration options set in main
23+ for other files dependency loading and application execution.
24+ -->
2025 < script type ="text/javascript " src ="libs/require.js " data-main ="main "> </ script >
2126 </ body >
2227</ html >
Original file line number Diff line number Diff line change 11/**
22 * require is global now, thus can be accessed by window.require;
33 * Require.js config API, takes require.js configuration object.
4+ *
5+ * @config -options:
6+ -> paths: Specify the path for js files; It is relative to the baseUrl;
7+ if baseUrl is not provided then by default baseUrl path will become the path where the require.js main file reference.
48 */
59requirejs . config ( {
610 paths : {
Original file line number Diff line number Diff line change 1+ /**
2+ * require is global now, thus can be accessed by window.require;
3+ * Require.js config API, takes require.js configuration object.
4+ *
5+ * @config -options:
6+ -> baseUrl: Specify the baseUrl Url, As baseUrl is specify the path for js files will change and will be relative to this baseUrl;
7+ */
18requirejs . config ( {
29 baseUrl : "libs" ,
310
@@ -7,6 +14,9 @@ requirejs.config({
714 }
815} ) ;
916
17+ /**
18+ * Require.js onError method to handle Async timeout error.
19+ */
1020requirejs . onError = function ( err ) {
1121 if ( err . requireType === 'timeout' ) {
1222 alert ( "error: " + err ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * require is global now, thus can be accessed by window.require;
3+ * Require.js config API, takes require.js configuration object.
4+ *
5+ * @config -options:
6+ -> shim (deps): Help to manage dependencies loading
7+ */
18requirejs . config ( {
29 baseUrl : "libs" ,
310
@@ -14,12 +21,15 @@ requirejs.config({
1421 }
1522} ) ;
1623
24+ /**
25+ * Require.js onError method to handle Async timeout error.
26+ */
1727requirejs . onError = function ( err ) {
18- if ( err . requireType === 'timeout' ) {
19- alert ( "error: " + err ) ;
20- } else {
21- throw err ;
22- }
28+ if ( err . requireType === 'timeout' ) {
29+ alert ( "error: " + err ) ;
30+ } else {
31+ throw err ;
32+ }
2333} ;
2434
2535require ( [ 'app/init' ] ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ <h1>JavaScript Module Loading using Require.js</h1>
1212 < p class ="lead "> How to run this example.</ p >
1313
1414 < ol >
15- < li > Open Example-5 .html in browser using any HTTP-SERVER.</ li >
15+ < li > Open Example-6 .html in browser using any HTTP-SERVER.</ li >
1616 < li > Press F12, go to console tab.</ li >
1717 < li > See the message get displayed on that console tab.</ li >
1818 </ ol >
Original file line number Diff line number Diff line change 1+ /**
2+ * require is global now, thus can be accessed by window.require;
3+ * Require.js config API, takes require.js configuration object.
4+ *
5+ * @config -options:
6+ -> shim (exports): Help to check it the provided library is AMD supported.
7+ */
18requirejs . config ( {
29 baseUrl : "libs" ,
310
@@ -13,12 +20,15 @@ requirejs.config({
1320 }
1421} ) ;
1522
23+ /**
24+ * Require.js onError method to handle Async timeout error.
25+ */
1626requirejs . onError = function ( err ) {
17- if ( err . requireType === 'timeout' ) {
18- alert ( "error: " + err ) ;
19- } else {
20- throw err ;
21- }
27+ if ( err . requireType === 'timeout' ) {
28+ alert ( "error: " + err ) ;
29+ } else {
30+ throw err ;
31+ }
2232} ;
2333
2434require ( [ 'app/init' ] ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * The goal of this file is to provide the basic understanding:
3+ * -> How to global object store
4+ *
5+ * How to run this example.
6+ * 1. Open Example-7.html in browser.
7+ * 2. Press F12, go to console tab.
8+ * 3. See the message get displayed on that console tab.
9+ */
10+
111define ( [ "config" ] , function ( config ) {
212
313 "use strict" ;
414
515 var url = config . url ;
6-
7- console . log ( url ) ;
8-
16+ console . log ( "Global Url: " , url ) ;
917
1018} ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @module : Global object; use to store global application setting.
3+ */
4+
15define ( [ ] , function ( ) {
26
37 "use strict" ;
@@ -6,5 +10,4 @@ define([], function() {
610 url : "http://www.google.com"
711 } ;
812
9-
1013} ) ;
Original file line number Diff line number Diff line change 11<!doctype html>
22< html >
33 < head >
4- < title > Example 6</ title >
4+ < meta charset ="utf-8 ">
5+ < title > Example 7</ title >
6+ < link rel ="stylesheet " type ="text/css " href ="../styles.css ">
57 </ head >
68 < body >
79
8- < h1 > Require.js Integration.</ h1 >
10+ < h1 > JavaScript Module Loading using Require.js</ h1 >
11+
12+ < p class ="lead "> How to run this example.</ p >
13+
14+ < ol >
15+ < li > Open Example-7.html in browser using any HTTP-SERVER.</ li >
16+ < li > Press F12, go to console tab.</ li >
17+ < li > See the message get displayed on that console tab.</ li >
18+ </ ol >
19+
920 < script src ="libs/require.js " data-main ="main "> </ script >
1021 </ body >
1122</ html >
You can’t perform that action at this time.
0 commit comments