At 1:26 PM -0400 8/11/07, Robert Cummings wrote:
On Sat, 2007-08-11 at 12:15 -0400, tedd wrote:
 > Always (fishing for another apology opportunity) place javascript in
 external files and call them in via the header. Keep the code
 unobtrusive. There are ways to use javascript without having to mix
 it into your html -- look up DOM scripting.

I absolutely agree with unobtrusive JavaScript, but I do disagree with
you slightly on using external files. Generally speaking i keep large
bits of code (Especially libs) in external files, but a few lines of
script for a form that appears on one page I'll often be put in the head
section. This way the JavaScript is in the same file as the template for
which it is associated. My template engine will relocate the JavaScript
to the <head> section at compile time.

That's clever. I assume that for production work (i.e., for a client), you can isolate the files you need and be totally unobtrusive if you want.

I just described my method off-list to another person and it went like this:

I have a system for my site development work such that I simply include one header and one footer and no matter where the project directory is that I'm currently working on, the process will find the one main common header and common footer and will add them to my demo automagically.

My code to start, looks like this:

<?php include('../header.php') ?>
   <h1> Hi </h1>
<?php include('../footer.php') ?>

From there I have a complete page -- from doctype to copyright, it's all there and it validates.

If I need a javascript file locally, then I add it to the local working directory by naming the file "a.js". Likewise, if I need an additional css file, then I name it "a.css" and it's also included in the call.

However, if I don't need those files, then none are included in my local working directory and attempts to load those files will fail -- however -- it doesn't matter if an attempt to load fails or not as long as the files are not needed.

I think that's kind of clever, but I like Rocky and Bullwinkle as well.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to