When is RequireJS' require call asynchronous? When is it synchronous?

前端 未结 3 1394
北恋
北恋 2021-01-02 18:21

I use RequireJS to load my modules in one of my projects. I see around the web different ways to require modules using the require call (and not define

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-02 18:58

    I don't know requirejs. But I think it's possible to load module in both sync and async ways.

    function require(name,cb){
        if(cb !== undefined){
            requireAsync(name,cb);
        }else{
            requireSync(name);
        }
    }
    

提交回复
热议问题