[Catalyst] javascript libraries in your application

Gene Selkov selkovjr at observercentral.net
Tue Feb 5 23:02:22 GMT 2008


Serving your javascript as a static resource is OK if your view really has 
a static behavior -- that is, it does not mutate as you change parameters 
in your request, or it is shared among multiple requests.

If it is not static, you may want to serve it as templates, in the same 
way you serve the screen templates.

For example, I have a set of somewhat similar views into a tree-shaped 
database. All these views share the same YUI tree component and the same 
AJAX dispatcher. But the way each view uses this component is not the 
same; the content of the nodes, and therefore the code for their 
construction is somewhat different, and the associated callbacks are 
entirely different; also, different sets of YUI modules are loaded to 
minimize load times, and the module dependencies are such that various 
modules must be included at a number of different locations inside the 
page. The behavior remains conceptually the same, but the details of its 
implementation differ so much that I have to separate and parameterize the 
variations. If I didn't do that, I would end up with a huge replication of 
my javascript code.

So I think the correct answer is, "it depends". If your client-side 
behavior is simple and does not vary, put it into static. Otherwise, there 
may not be a good place for it. It may have to be designed and architected 
in the same way you do it with you server-side code.


--Gene



On Tue, 5 Feb 2008, Mesdaq, Ali wrote:

> I put mine under root/static/js during testing and development but on
> live servers I put it under /js and use mod rewrite rules to allow that
> and the images directory to be served up statically. For some reason
> having /static/js on a live URL is ghetto to me.
>
> Thanks,
> ------------------------------------------
> Ali Mesdaq (CISSP, GIAC-GREM)
> Security Researcher II
> Websense Security Labs
> http://www.WebsenseSecurityLabs.com
> ------------------------------------------
>
>
> ________________________________
>
> From: Dennis Daupert [mailto:ddaupert at gmail.com]
> Sent: Tuesday, February 05, 2008 11:43 AM
> To: The elegant MVC web framework
> Subject: Re: [Catalyst] javascript libraries in your application
>
>
> On Feb 5, 2008 2:04 PM, Jennifer Ahn <jenahn at stanford.edu> wrote:
>
>
> 	hello!!
>
> 	i just started building my web application on catalyst and i'm
> wondering
> 	where to put my javscript library in the framework.
>
>
>
> Usually you want your javascript library to just download to the client
> as is,
> so under root/static is a good place. I like to set dedicated
> directories for
> static files:
>
> root/static/js
> root/static/css
>
> /dennis
>
>
>
>
> Click here
> <https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==
> JgBaACSDeMXQWRz9bcREXBI5WqhMaOjSoV05X3tupocxOU+hzbZ!McXk8aO1IcCWTJm2e1JR
> kak83gA7i1ZX0Rh0pjvjOVVc6jcNlB8Ds4+JocbhkZWBW7!0F73cQW1dwOla+spYSJAy!Vv4
> KBKU6lr3gM0bZYMcdwivWgSmGe9NjQAjWNIXit9O>  to report this email as spam.
>
>
>
> Protected by Websense Messaging Security -- www.websense.com
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list