2009/8/12 Johannes Geppert <jo...@web.de>

>
> Hello Eric,
>
> thank you for fast response.
>
>
> Obinna wrote:
> >
> > What I have done is to put all of the meat of the javascript code into a
> > single file which is included in the sj:head and then just have a small
> > binding snippet code rendered with each tag which calls a binding
> function
> > in the main .js file.
> >
> I think also about this, but i dislike some thinks.
>
> 1.) When supporting all Widgets and interactions with one javascript file,
> this file grows really fast.
> 2.) This big javascript was loaded on every single page
>

Typically it would only be loaded once and cached by the browser. Compared
with the jquery core files which have to be loaded anyway, the file size
should still be small. For example the current file I have, minimized, is
about 26K versus jquery-ui which is 186K and jquery which is 57K. And I'm
sure I could decrease this by quite a bit if necessary.
It doesn't necessarily have to be a single file. You could have a base file
with the core code and a separate .js file for each widget/component and you
could perhaps even include code to lazy-load individual files as necessary
(probably overkill though). Given the file size, at least at the moment, it
is still much easier to deal with a single file.


>
> 3.) When I use the standard jQuery way, the user know it and can better
> find
> there own failures and can report better error messages
>
I'm not sure what would be the 'non-standard' jQuery way? Moving the
javascript code into a .js file from the templates shouldn't change
anything.

>
> 4.) For my opinion is a large javascript file harder to debug and maintain
> as some freemarker files


I actually find the reverse to be true. But the main point is that if you
want to support multiple template engines it would be a nuisance (and
debatably poor practice) to duplicate the .js code in each of the template
engines files. I actually started out that way but quickly changed to a
consolidated .js file because I was trying to support both freemarker and
javatemplates template engines (I have since abandoned javatemplates support
though).

- Eric

>
> Obinna wrote:
> >
> > This way, the addition to the freemarker templates is almost thoughtless
> > and
> > the you don't place the (IMO) overburdening requirement to add yet
> another
> > <footer/> tag for the developer.
> >
> You are right, and it was just an Idea. Maybe it can be optional.
>
> -----
> ---
> web: http://www.jgeppert.com
> twitter: http://twitter.com/jogep
>
> --
> View this message in context:
> http://www.nabble.com/Create-a-single-javascript-tp24935752p24937153.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>

Reply via email to