简体   繁体   中英

Many requests to server with dojo

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.Tooltip");
dojo.require("dojo.parser");
dojo.require("dojo.fx");
dojo.require("dojo.dnd.Manager");
dojo.require("dojo.dnd.Source");
dojo.require("dojox.layout.ContentPane");
dojo.require("dojo.io.iframe");

This appears with CDN or with src="", and show in inspect element in my page a lot of requests, someone know why?

Well, It seems you want to understand the flow of Dojo I mean how it works and how it loads its dependencies.

In above snippet code as we can see you are using legacy model/version of dojo

First we understand the require and define

require and define are part of the asynchronous module definition (AMD) API.

You use define to define a module that can be consumed by other code. Generally, define will be used in a javascript file. The javascript file is defining a module. All Dojo files use define.

You use require when you are not defining a module, but you require modules that have been defined.

Loading of widgets

So in your network and console you can observe that whenever you load the dojo cdn link it simply loads the init.js default loader file. very small in size and easy/faster to load.

So once your dojo loader is loaded based on your dojo configuration then it start looking for dependencies which you are using in your project so which ever widgets ( dojo controls, classes, files etc. ) you mentioned in require it will start loading those widget from CDN.

In this case dojo doesn't load the whole dojo library in your prject it simply loads only those widgets which you mention in require .

Hoping this will answer your concerns :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM