RequireJS: Multiple main.js?

The requirejs team has some samples for multipage applications on github.
Have a look at: https://github.com/requirejs/example-multipage

Basically you are going to have the following structure:

  • page1.html: page 1 of the app.

  • page2.html: page 2 of the app.

  • js app: the directory to store app-specific modules.

  • lib: the directory to hold third party modules, like jQuery.

  • common.js: contains the requirejs config, and it will be the build target for the set of common modules.

  • page1.js: used for the data-main for page1.html. Loads the common module, then loads app/main1, the main module for page 1.

  • page2.js: used for the data-main for page2.html. Loads the common module, then loads app/main2, the main module for page 2.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)