Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AMD/Dojo 1.7 Single Page App: Where to put the Require()'s?

I've got a large scale single page app that I'm migrating to Dojo 1.7/AMD loader syntax.

I've got a main JSP that loads everything, and then a multitude of JSP pages that are used for dynamic content generation.

Is it a better design decision to add the require(){} block around the entire application, or around each instance of a requisite module?

Or some combination? Add the most common require()'s to the main page, and then go through and find other instances that need to be wrapped?

like image 994
mtyson Avatar asked Oct 07 '22 10:10

mtyson


1 Answers

You should lazy-load as much as possible; perhaps at the "dynamic content" JSP page level. It makes it very clear about what each page requires, and keeping the requires() close to the code that uses the imported module is clearer.

It also reduces the amount of time the main page takes to load, which means the user can interact with the application in a shorter amount of time. This is a Good Thing.

like image 184
craigforster Avatar answered Oct 10 '22 09:10

craigforster