[Seaside] CSS/JS libs
Avi Bryant
avi at beta4.com
Tue Jun 22 20:26:21 CEST 2004
Hi all,
One of the things I've been focusing on in the 2.5 release is making
Seaside streamable - by which I mean, that it's possible to push the
HTML directly out to the socket as it is generated, rather than
collecting it into a buffer or DOM. This should improve performance
under load, and the perceived performance for the user, since the first
data will hit the browser sooner. And, by and large, it hasn't
required much in the way of design changes.
One area where I'm running into trouble is that of CSS files. These
need to be linked in from the <head> section, which in a streaming
model has to be complete before the <body> starts. That means that all
of the needed external CSS has to be determined before rendering any of
the body. This is fine for #style methods on components (we can use
#children to collect all of these before starting to render), but it
doesn't allow for tricks like StyleGroup
(http://lists.squeakfoundation.org/pipermail/seaside/2004-May/
003047.html), where stylesheets are brought in on demand as IDs or
classes from their "group" are referenced. A similar problem exists
for Javascript: ideally the <head> section would bring in any needed
Javascript code, but we can't know for sure what's needed until we've
rendered the page. In the case of Javascript, we can use <script> tags
in the body itself, but at the least there's some cumbersome management
needed to ensure that we don't include the same script multiple times.
What I'm leaning towards as a simplification is to abandon the idea of
bringing in stylesheets and supporting scripts as needed on particular
page views, but to work at a much coarser granularity: styles and
scripts will be grouped into "libraries", and each application will be
configured with which libraries it includes. All of the styles and
scripts in the included libraries will be referenced from the <head> of
every page in that application. The URLs for each individual snippet
of CSS or JS are immutable and have no expiry date, so the browser
should cache them indefinitely. However, this will increase load times
for the very first page of the application, and it will doubtless mean
having some scripts and styles included that don't get used at all.
What are people's thoughts on this?
Avi
More information about the Seaside
mailing list