Following up on last night's deployment improvements in the Dart version of the ICE Code Editor, I hope to be able to finish up today. Whereas yesterday I shrunk the application payload with the
dart2js, today I would like to shrink the payload by being a bit more judicious with what needs to be downloaded.
Taking a look at http://gamingjs.com/ice-beta/ (which currently holds the Dart version of ICE) in an incognito browser session, I find:
--minifyoption, and ICE should be in fine shape.
There is an obvious gap in the transfer of files. What gives? And if I can eliminate it, will the download go even faster?
... Application Cache Progress event (95 of 100) http://gamingjs.com/ice-beta/part.js.map Application Cache Progress event (96 of 100) http://gamingjs.com/ice-beta/packages/unittest/src/utils.dart Application Cache Progress event (97 of 100) http://gamingjs.com/ice-beta/packages/ice_code_editor/full/rename_dialog.dart Application Cache Progress event (98 of 100) http://gamingjs.com/ice-beta/packages/unittest/src/test_case.dart Application Cache Progress event (99 of 100) http://gamingjs.com/ice-beta/packages/js/src/wrapping/typed_proxy.dart Application Cache Progress event (100 of 100) Application Cache Cached event Document was loaded from Application Cache with manifest http://gamingjs.com/ice-beta/editor.appcacheSo it seems that I may be putting just a little too much into application cache. Well, maybe a lot. Considering that loading the editor and the default project only required 18 requests, I am almost certainly loading way too much.
A closer inspection shows that #96 and #98 of the application cache files are unit test files—those certainly are not needed in application cache. They probably do not need to exist on the server at all. But even more so, there is absolutely no reason to jam a single Dart file into application cache. There is not a single production browser that supports raw Dart, so I am forcing ICE users on http://gamingjs.com/ice-beta to download a bunch of files for no reason whatsoever. Sorry about that.
Application cache beasts, like the ICE Code Editor, need a manifest file on the document's
<!DOCTYPE html> <html manifest="editor.appcache"> <head> <title>code editor</title> <meta charset="utf-8"> <script src="appcache.js"></script> <script src="packages/browser/dart.js"></script> <script src="packages/browser/interop.js"></script> <script src="main.dart" type="application/dart"></script> </head> <body> </body> </html>This manifest file informs browsers what they need to down for the application to function properly:
CACHE MANIFEST # 2013-07-10 CACHE: /favicon.ico /Three.js /Tween.js /Detector.js /physi.js /Mouse.js /Scoreboard.js /ChromeFixes.js /ammo.js /physijs_worker.js part.js main.dart index.html main.dart.js.map main.dart.js packages/js/js.dart packages/js/src/wrapping/js/object_to_map_adapter.dart # Many, many, many more files... NETWORK: *The asterisk in the
NETWORKsection of my manifest says that anything not explicitly listed in the
CACHEsession should downloaded over the network. I really ought to allow all of the Dart code, along with any supporting resources, to get served up over the network. I can still leave them on the server, in case a Dartium browser comes along, but not place it in application cache.
After excluding a bunch of files, I get my list down from 100 to 33:
➜ ice-beta git:(gh-pages) ✗ cat editor.appcache | grep -v \\.dart$ | \ grep -v pubspec\\. | \ grep -v unittest | \ grep -v inconsolata | \ grep \\. | \ wc -l 33That is much, much better because, as everyone knows, individual files have a much greater impact on download speeds than do large files.
I find that I can generate the same list of worthy application files with a
➜ ice-beta git:(gh-pages) ✗ find | \ grep -e \\.js$ -e \\.map$ -e \\.html$ -e \\.css$ | \ grep -v -e unittest -e /lib/ | \ wc -l 22There is some duplication in the
lib/sub-directory that I do not fully understand (it may just be how I coped it last night). That is something for another day. For now I ignore them in the
grep -v(ignore) statement.
I am explicitly ignoring the
dart2jsgenerates. I should probably dot-gitignore that file—it includes local file URLs:
file:///home/chris/local/dart/dart-sdk/lib/_collection_dev/arrays.dart file:///home/chris/local/dart/dart-sdk/lib/_collection_dev/collection_dev.dart ...
I do need to manually add the
main.dartscript to the application cache manifest—the browser does request it even if it does not know how to process it (because it is in a
<script>tag in the HTML). With those changes, my entire manifest file contains:
18 requests ❘ 103 KB transferred ❘ 1.39 s (load: 1.37 s, DOMContentLoaded: 187 ms)
Ultimately it does not matter too much. I am still looking at a load time of less than 1.5 seconds for the first access, which is pretty darn good. Subsequent access will be even better since it never even touches the the network—the benefits of being stored in application cache. The
And if I find that I need much better, there is always SPDY!