- Reducing the load on your own server
- Speeding up the delivery, as a Content Delivery Network (CDN) is used to ensure that the server is as close as possible to the client, and
- The more people who use this the better, as the same Dojo files will be cached when users move from site to site, as they’ll all be downloading the AOL hosted files.
- Gzip compression as standard, so the files are as small as possible
However, the problem comes in where you want to use your own custom code with the hosted Dojo code. This is because the hosted code uses Dojo’s loading system to dynamically load the resources needed on the page, and this will read the files from AOL, not your server (as you would expect – it knows nothing about your server). If you want to build custom layers to improve performance, the remotely hosted Dojo will not be able to find them.
Notice here that the file I load is dojo.js, the normal version, not dojo.xd.js, which is the cross domain version capable of loading files from AOL.
After doing this, you can then include whatever custom built layers you like onto an particular page. For example, if you have a layer built for the dojox.image.Gallery widget called /js/dojo/dojox/image/Gallery-layer.js, you can load it either dynamically:
or include it via a script tag:
and it should work just as if you were using Dojo from your own server. Only of course you are not – AOL is serving up that file, and in many cases users will already have cached that file, speeding up your site quite nicely.
Another approach is to create a custom namespace, register it with Dojo, and put all your layers in there…. but that’s for another post 🙂
Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt