[Bese-devel] javscript files, large dojo.js and modularization

Denys Rtveliashvili rtvd at mail.ru
Tue Jul 25 16:42:50 UTC 2006


Hi,

Taking another look into the source of the "Form demo" page I noticed
that even though the dojo.js was loaded and "dojo.event.*" was
requested, there was no strong reason to use dojo there. For instance,
the only use of dojo was to find a page element by it's name. Of course,
dojo.byId is much shorter than document.getElementById, but I think it's
possible to get rid of dojo in this case of usage.
So, it seems that it is possible to evade dojo in some cases, even if it
seems that a complex javascript is needed there.

Probably I could reduce the dojo code if I spend some time, but:
- as I see, dojo is a completely separate project and it's interesting
what dojo authors think about making dojo.js thin.
- it seems  that the dojo.js is generated automatically. You can notice
strange variable names like _85f. So maybe it will be necessary to
improve the javascript generator, not dojo.js itself.

The dojo.js I have in my version of ucw_ajax is more than 200KB large.
But after gzipping it becomes smaller and it's size is less than 60KB.
If UCW can handle static content properly so that web clients can use a
cached version, that will partially improve situation. And if UCW can
transparently zip the files that are sent to client side then it is even
better. But I did not check that yet.



I also believe that modularization is a good thing to have. Sometimes
it's difficult to achieve it, but if it exists, the results are usually
beautiful. Its not only a possibility to use only that parts of
functionality which are really necessary. It is also an easier to read
code (but for me the major difficulty is the LISP syntax :)) and a
smaller amount of bugs, because they tend to lurk in a dark places where
all pieces of program are bound together in strange ways.



As for my progress, I extracted almost everything into a separate .js
and now I am thinking about doing another change: merging all
form-related javascript into a single piece of code to evade duplication
of <script>...</script> tags.

By the way, if somebody is interested to see what I have already done,
please let me know and I will send you a patch.
I am still not familiar with development process in UCW, so I do not
know where should the patches be sent to and what are "DOs" and "DONTs"
in the development.

--
Thank you,
Denys R




More information about the bese-devel mailing list