compy icon indicating copy to clipboard operation
compy copied to clipboard

async require

Open edjafarov opened this issue 12 years ago • 1 comments

Right now everything is built in single js file, which is awesome since removes require.js complexity. Though it is reasonable that in certain cases some sources we need to load asynchronously. And there are cases where we need to load script from 3rdpaty server (to use API for example)

problem

  • Compiler actually adds/wraps all js resources in single file. There is no way to explain what resource should be loaded and what not.
  • We have no way to block js execution while requiring

solutions

  1. we can put comment in the beginning of file
// async

and customize compiller/or pattern matcher in grunt 2) build some kind of api to do that, I would say:

var asyncRequire = require('async-require');
asyncRequire(['../module_name.js', function(moduleName){
   execute
}])

edjafarov avatar Sep 16 '13 16:09 edjafarov

:+1:

Pickachu avatar Oct 31 '13 13:10 Pickachu