FileField currently adds its CSS in filefield_init(). This results in this CSS being loaded even if not used. The effect is small but not insignificant, especially when you consider the cumulative impact of CSS bundling, gzip and minification on each request.

Ideally FileField would insert the CSS on its first use, perhaps using an initialization routine called each time CSS-using output is generated (theme_*/form_* functions?) that checks a flag to detect whether it had already been inserted.

If the CSS is used by dependant modules without further calls back to FileField, it might be necessary to add a call as part of their own first-use initialization. Don't know enough about FileField to say.

Comments

quicksketch’s picture

There's sort of an on-going battle about where to add CSS. For a small CSS file, it's actually benificial to add it on EVERY page of the site when the CSS aggregation is turned on. The more consistent the CSS files are added, the fewer different CSS files need to be generated. Considering that filefield.css is likely used on most pages of the site, we decided just to add it on all pages to generate fewer aggregated CSS files.

quicksketch’s picture

Status: Active » Closed (won't fix)