CMXtraneous

Right on the edge of useful

Let the Holidays Begin!

Posted Wednesday, October 27, 2004 4:16:44 PM by Jim Babbage

Jim Babbage
Ahhhh, All Hallow's Eve is fast approaching. I love Halloween. I get right into the spirit of things, as it were. Yep, Halloween-slanted FW tutorials here on CMX, Halloween decorations around the house (some grisley, some cute, like my vampire Snoopy!), hoards of treats for the kiddies who come a-knocking on the 31st of October and the list goes on.

I also get a kick out of some of the costumes, and how cute or funny some of the children are, all dressed up. Some of them - young as they are - are very nervous about approaching our scary little home that night, much less ask for treats.

This weekend, my niece and nephew are coming over to carve pumpkins and eat pizza. They'll also help me dress up the front lawn with various scary artifacts, such as a hanging skeleton, various body parts, bugs, even a fresh grave or two. Yes, it's a fun day.

Of course, all this is just a lead-up for me to the BIG holiday. Yes, dare I say it . . . Christmas! See,  Thanksgiving has already come and gone up here in Canada; we have to catch and eat our turkey before it gets stuck in the ice, don't cha know. So the next biggie is Christmas.

If I'm a big Halloween celebrator, then I am an absotively HUGE Christmas fan! The whole house gets decked out . . but that story is for another time.

Well, I have one more tutorial I want to wrap up before Halloween leaves us for another year. I best get back to it.... BWA HA HA HA HA!

Happy Halloween, one and all!

Category tags: This and That

Using Dreamweaver's Find and Replace to reduce code clutter and decrease file size

Posted Wednesday, October 27, 2004 1:24:39 PM by Zoe Gillenwater

Zoe Gillenwater

Clean code can make a big difference: 30 kilobytes worth of difference in my case.

I'm currently working on a project where I have to take Word documents (really, really large Word documents) and convert them into an accessible format for the web. To get them into a clean, html state, I took the following steps:

  • Use Word's "save as web page" feature.
  • Upload Word's htm file to Textism's Word HTML Cleaner tool to strip out all the MS junk.
  • Save cleaned html to a new file.

At this point, I have clean html, but it's still not as streamlined as it could be. The original Word document was basically a series of data tables, and Word exported them as such, thankfully. But, it wrapped the content of each cell in a paragraph element. So, it looked something like this:

<tr>
<td width="12%" valign="top"><p>AADT</p></td>
<td width="43%" valign="top"><p>WEIGHTED AVERAGE TOTAL ADT</p></td>
<td width="17%" valign="top"><p>ROADLOG</p></td>
<td width="13%" valign="top"><p>NUM</p></td>
<td width="13%" valign="top"><p>59</p></td>
</tr>

While these paragraphs were not invalid, they were unnecessary and unsemantic. I wanted to get rid of them. So, I opened up Dreamweaver's Find and Replace. Under Search, I selected Specific Tag, then selected p. In the next row, I selected Inside Tag, then selected td. Under Action, I selected Strip Tag. What all this means is that Dreamweaver would look for any paragraph elements inside of td elements and strip out these tags, but not their content.

I clicked Replace All and let Dreamweaver do its work. It stripped out 2633 instances of p elements inside of td elements, so now it looked like this:

<tr>
<td width="12%" valign="top">AADT</td>
<td width="43%" valign="top">WEIGHTED AVERAGE TOTAL ADT</td>
<td width="17%" valign="top">ROADLOG</td>
<td width="13%" valign="top">NUM</td>
<td width="13%" valign="top">59</td>
</tr>

While the change doesn't look very dramatic from the markup I had before, my file size had decreased from 310 kb to 280 kb – that's a file size decrease of almost 10 percent! This is why clean code matters: removing extra, seemingly harmless tags can really add up and make big differences in file size, which in turn can make big differences in how easily your visitors can use your page, how much your client has to pay in bandwidth, and even how well your page ranks in search engines.

Next up: removing those width and valign properties. I'll let you know how many additional kilobytes I strip out.

Category tags: Dreamweaver