Dojo on a CDN vs own install

2019-05-08 06:51发布

问题:

I use quite a lot of Dojo, but to date I've only used it by including from a CDN such as AOL/Google.

Are there advantages to hosting a copy of Dojo rather than using it via a CDN? I don't have much need to alter the code base, but I imagine there are other advantages/disadvantages?

回答1:

by hosting your own Dojo env. you are for example able to make a custom build of dojo. So you only need to load one *.js file. That saves traffic used by the xhr requests.

-jstr



回答2:

Disadvantage to hosting anything externally is that you don't have control over it. You won't get this with the Google/AOL CDN but you could land up with the same issue that BootyCall got when using Doug Crockfords json.js from his site. http://ajaxian.com/archives/doug-crockford-and-the-online-booty-call-saga

Advantange is that you don't have to pay for bandwidth and will have the correct expiries added to it all the time



回答3:

+1 for the custom build.

We use Dojo in a product that is not guaranteed to have access to the internet, so we ship with Dojo embedded as part of our product.



回答4:

Isn't it possible to combine the two approaches? I've tried to configure my dojoConfig to have the following baseUrl //ajax.googleapis.com/ajax/libs/dojo/1.8.3/, and at the same time the script tag points to a custom dojo build file. The problem is, when I load the custom dojo.js the NLS files (e.g. dojo_en-US.js) are not loaded. Couldn't find a workaround.

As I see it, as long as the deployment environment is open to CDN, this would be the best solution, for several reasons (as others already stated): 1. Custom dojo reduces XHR and improves performance 2. In case custom build is incomplete (someone added a require), the XHR is served much faster 3. There are resources (such as images) that cannot be embedded in the custom build, and so loading them from CDN is preferred 4. Packaging and deployment of the application is much faster, because it should only contain the dojo.js file, and not the entire dojo release resources.

I would be happy if anyone could prove me wrong and tell me how can I combine the two approaches.

Thanks, Lior



标签: dojo cdn latency