[ Feeling guilty about cross-posting to 4 lists ... ]
On Fri, 9 Sep 2005, Rob Kinyon wrote:
> 2) Serverside strategies - this is epitomized in Dave Rolsky's
> JSAN::ServerSide, available on CPAN. Basically, the webserver will
> modify the outgoing page so that all the dependencies are in the page
> as <script> tags, in the right order. All modern browsers cache the
> results of <script> tags, so this provides for session-level caching.
Note that this is still missing support for JSAN exporting. I really need
to work with Casey on that some time now that we are cow-orkers.
> This requires mod_perl on the server.
Does not! Though it'll certainly be more efficient this way. There's
nothing mod_perl specific in JSAN::ServerSide.
> 4) JS header files - this is a second file containing the dependencies
> would be created, either manually or with some tool. JSAN.use() would
> then be rewritten to use either DOM injection or document.write() to
> add TWO <script> tags on the fly. The first would be the header (.jsh)
> file and the second would be the code (.js) file. This similar in
> concept to the bootstrap script that MochiKit uses. This requires
> nothing from the user, but it does require some work on the part of
> the developer. In addition, some scenarios still don't work, such as:
I'm not sure who you mean by "user". If you mean consumer of a JSAN
library, then it does require extra work on their part, becase they have
to keep their own headers up to date if they want to use JSAN in their own
code.
> I'm not looking for the "One True Way"(tm). Several of these strategies
> can be used in tandem. What I am looking for is group consensus on the
> "One True Way"(tm) for each of these strategies, and also if the group
> feels that a strategy sucks too much, that it should be dropped. I feel
> we need to bring the group's talents to bear on a few good methods, so
> that we can speed adoption and get this monkey off the project's back.
> The first question people ask me is "What's performance like?" and I
> have to tell them "It can suck, depending on the client." At that point,
> I lose them, and that's a "Bad Thing"(tm).
I would say the following is a good path to pursue:
- Recommend a server-side approach for people doing dyanmic server-side
dev. The server-side implementation is fairly trivial, and should be
relatively easy to encapsulate in libraries for various server side
languages.
I think this is the best approach when possible because it makes JS
development very simple. JS code needs no extra pre-processing to be
deployed, and error messages come from the expected files (unlike XHR).
It also means that each page only loads the JS it needs, which I think is
useful. I like to know what server-side code paths require a given JS
library.
- Recommend header files + script tag injection for pure HTML + JS
development. This requires creating a header generating tool, but that's
no harder than writing the server-side dependency generator (in fact, it's
mostly the same code).
This seems simpler to me than concatenation, which would tend to generate
monster script files. Concatenation also akes it hard to see what a given
page is using, since every page would load everything, and it will
seriously obscure debugging.
I also wonder if concatenation will have scoping issues, but
I don't understand of scoping in JS 100%.
- Support XHR as a fallback for quick prototyping. It's the easiest way
to get up and running with JSAN. I think making it clear that this is
undesirable for production is fine, as long as migration paths to other
import methods are well-documented.
-dave
/*===================================================
VegGuide.Org
www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/