[dojo-contributors] dojo.requireCss()?

James Burke jburke at dojotoolkit.org
Tue Jun 12 14:16:14 EDT 2007


I recently ran across an issue with the dijit wai.js file doing a test
for a CSS property on an element to determine if the browser was in an
a11y mode. I outline some of it here:
http://dojotoolkit.org/forum/developer-forums/dijit-development/dijit-css-race-condition-a11y-check

The basic core of the issue seems to be that CSS files are not
guaranteed to be loaded when our domcontentloaded/onload callbacks get
fired (or maybe it is an issue just with @import).

Additionally, in 0.9, we need to load the CSS files ourselves,
specifying URL paths to them. However, I find this lacking, and not
keeping with the abstraction that dojo.require/dojo.provide loading
gives me. Our loader allows me to specify a root path once (either via
the path to dojo.js and/or dojo.registerModulePath()), then not have
to worry about paths after that. If I change where I load dojo from
(either different path or an xdomain build) that normally means I just
have to change that path once, and I'm set. Not so with the CSS files
in 0.9.

So to address the async loading issue with stylesheets as well as the
path abstraction, I'm wondering if we can support something like
dojo.requireCss(). It would resolve paths like dojo.require() does
today and also treat the CSS as a resource that needs to be loaded
before firing the domcontentloaded/onload callbacks. Example:

dojo.requireCss("dijit.themes.dijit");

which would map to dijit/themes/dijit.css. dojo.requireCss would pull
in the CSS contents, fix the css paths and inline the CSS via
something like the old insertCssText. It could process @import calls
to files that mapped to module-prefixed paths too.

The icing on the cake: specifying an i18n bundle in a CSS comment that
should be loaded and allow token replacement with bundle values in the
CSS. This step could maybe be an optional add-on (since it depends on
i18n and string replacement code), but something I could have used
before.

You would not be forced to use dojo.requireCss() as long as you are
fine dealing with the possible async loading issue, and changing
multiple paths as you move dojo.

This would impact core, and probably base, since the loader is involved.

James



More information about the dojo-contributors mailing list