Creating your own utilities is a good thing. I have one like that for
prototype. There are some handy methods that were missing on elements.
I always try to be close to the library i use.

[off topic]
By the way: Most of the methods on the site you posted are all
included in prototype, btw.

- cssQuery is basicly $$
- inArray = include()
- inserAfter = Insertion.After
- getElementsByClass = same name
- Event.observe for event things.

I stopped creating my own utility library, 'cept for the custom
element methods said. Most stuff you'll probably ever need is covered
in all major libs already + you benifit of the ever-debuggin community
behind those functions. I avoid snippets most of the times. You never
know if they are properly tested and save.
[/off topic]

Crunching Javascript:
I am currently evaluating on the fly server-side packing of my
scripts. I said i have the .htaccess for the gzip compression. I went
a little further tho: The packer from Dean Edwards - which crunchs
javascript files to a minimum - exists as PHP class. I included that
one into the compression.php and it works like a charm.

You can work in the editor with the original source and when you
refresh your cakephp app the packer will crunch it (and gzip). I think
that covers everything you could possibly do to deliver your scripts
fast and small.

http://dean.edwards.name/packer/

Keeping it fresh:
Another trick is to read the file modification time and append it to
your js file links.
Should looks like this: src="js/myproject.js?20070402_2348"

The compression.php set the cachetime to 5 hours (or something..), but
we might want to force updates on the clientside. Preferbly when we
last edited the file of course.

Here is where the file modification time jumps in. If the sript src
changes due to date changed on the file (upload/save), the user
downloads the new source because it does not match with the filename
in his cache anymore. This only happens once of course. Then the
cachetime is in effect again.

Happy coding

On 4/7/07, beetlecube <[EMAIL PROTECTED]> wrote:
>
> Thanks for sharing how you do that, Kjell.
> That was definitely helpful.
>
> I know I will eventually decide on one of the major frameworks to
> adopt permanently.
>
> But sometimes, you're sitting lazily at the PC on a Sunday afternoon,
> reading blogs or whatever, and you come across a Javascript function
> that you want to add to some permanent library somewhere,  and this
> function isn't in whatever Framework I adopted, so I add it to a
> central generic utility JS file that grows and grows (and of course
> shrinks sometimes when I realize I've added junk to it as well.).
>
> What prompted my post originally is when I ran into this page:
> http://www.dustindiaz.com/top-ten-javascript/.  Even though it's over
> a year old, there's a couple of handy things in there, so keeping
> organized  allows one to, on the fly, add something useful that one
> runs into on a website.
>
>
> On Apr 6, 1:46 pm, "Kjell Bublitz" <[EMAIL PROTECTED]> wrote:
> > I put framework related files into one directory under /js/
> > Like jquery + all the plugins i use.
> >
> > I name the folder usually after the frameworks name: yui, prototype, etc..
> >
> > /js/jquery/jquery.core.js
> > /js/jquery/jquery.cookie.js
> > /js/jquery/jquery.tooltips.js
> >
> > So the top folder is usually empty, but i put there my .htacces for
> > handling all JS requests  and redirect them to my php script for gzip
> > compression and cache settings.
> >
> > There is only one javascript file on the app/webroot/js/ root,
> > and thats the one with my custom code.
> >
> > It is usually named after the projectname.
> >
> > /js/.htaccess
> > /js/compression.php
> > /js/myproject.js
> > /js/prototype/prototoype_version.js
> > /js/prototype/event-selectors.js
> > /js/prototype/datepicker.js
> >
> > For your described case of using js-files outside: I never work this
> > way. I put everything there that i need for the app. If i need it
> > outside, i just copy it.
> >
> > The other way around is: If there is a vendor-app that i include and
> > it has own javascript files i move them to the cake app/webroot/js
> > directory for consitency. But i never had it that way either.
> >
> > Lets say i have javascript functions that i only need on the profile
> > action of my users controller i simply extend the filename like so:
> >
> > /js/myproject-userprofile.js
> > /js/myproject-eventcalendar.js
> > etc..
> >
> > For me, this is perfect to manage.
> >
> > On 4/6/07, beetlecube <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > I know that many Cakephpers  use frameworks/libraries like  Prototype
> > > and JQuery.
> >
> > >  What about if you come across some general purpose Javascript
> > > functoin and you add those to a "common.js" file that you keep
> > > accumulating to ?
> >
> > > And I'm talking about a common.js type file that you might use even
> > > *outside* of your CakePHP websites.
> >
> > > If you keep this general purpose common.js file inside you app/js
> > > directory, but you also use *elsewhere*, then pretty soon they become
> > > un-Synchronized, like if you forget to make a copy of one to the other
> > > location after making changes to only one of them.
> >
> > > I think it's a common challenge some of us face -- or not.
> >
> > > Wondering what you guys do.
> >
> > > Steve
> >
> > --
> > Regards, Kjellwww.m3nt0r.de
>
>
> >
>


-- 
Regards, Kjell
www.m3nt0r.de

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to