Re: Include .js file for server side and client side
Julian Tree <julian.tree <at> gmail.com>
2006-01-03 23:25:29 GMT
Ah, Christ thanks a lot. But do you know if there is any performance
penalty of having hac file reading from the file system?
Depending on the browser, I know when php load a staic js file through
the script, it will cause the browser to reload the the js file
everytime the user hit the page. Where as a static js file will be
cached, and it will only be reloaded from the server when user hit the
"Reload' button.
I was hoping for a way to allow the browser to statically include the
.js file and allow the server side to use that .js as well. But may
Helma on Jetty can handle connection request much better than PHP on
Apache. Thanks for the response again.
Tree
On 1/3/06, Chris Zumbrunn <chris <at> zumbrunn.com> wrote:
> On Jan 3, 2006, at 5:46 PM, Julian Tree wrote:
>
> > I have a validate.js lib file that I used to do all kinds of
> > validation such a check date format, time format, string max length,
> > credit card, etc. Now, I would like to use this file both on the
> > client side and server side, for user input validation.
> >
> > If I put this file in the static dir, then I can include it on the
> > client side such as
> > <script type="application-x/javascript"
> > src="static/validate.js"></script>
> >
> > But then I can't have the same file in Globals/
> >
> > Is there a way to just have one file and have it included on both the
> > serverside and clientside?
>
> Hi Julian,
>
> I've shared code between client and server side using the following
> trick:
>
> Root/validate_js.hac:
> res.contentType="application/javascript";
> var codefile = new helma.File(app.dir+'/Global/validate.js');
> res.write(codefile.readAll());
>
> Would that solution work for you?
>
> Chris
>
> _______________________________________________
> Helma-user mailing list
> Helma-user <at> helma.org
> http://helma.org/mailman/listinfo/helma-user
>