javascript - Migrating established web application to using requirejs - how to ensure modules are loaded when we need to use them? -
our pages constructed jsp. have large page specific javascript files in process of refactoring modules. far, have script tag in head load requirejs. data-main js file loading require.config settings , includes callback function require(['common/useragent']); useragent module loaded.
the page onload() calls function in big page specific js file needs useragent module, when function tries require('common/useragent') error saying hasn't been loaded yet , use [] load it.
also, our page has many scripts tags intermingled html , we'll need use these modules code.
i'm trying follow multi-page example except in 1 loading page.js data-main js file. see why important ensure dependencies loaded defined.
is there way ensure dependencies loaded when not in requirejs module have defined dependencies in define(). mean can these requirejs modules straight javascript using require() function without worry whether module has been async loaded yet, or not?
Comments
Post a Comment