By Nathan L. Walls

  • Shows/Raleigh
  • Blackberry Blossoms/Raleigh
  • Blackberry Blossom/Raleigh
  • .

Articles tagged “web development”

IE and JavaScript MIME-type lessons

I’m a jQuery-fan and I recently wrote some forms for CrazyLikeThat using jQuery and AJAX. The goal was to use a Rails application I wrote as a service.

I hit a few roadblocks, though and in solving them, learned some things:

  • While ‘application/javascript’ may be the recommended type attribute to source in Javascript with the >script /< tag, IE doesn’t follow it. Regardless of what MIME-type your server sends JavaScript as, you have to specify 'text/javascript’ to IE.
  • IE8 has three rendering modes, and there are implications for how to interact with the DOM based on which mode you’re in.

Apache Server Side Include directives for local web development

I’m developing some JavaScript to interact with a Rails service I have in support of CrazyLikeThat.com. I’m an infrequent jQuery developer, so I spend a lot of time in WebKit’s Web Inspector. I also use Google Analytics and Google AdSense. In the middle of looking at the Web Inspector console, I noticed a blizzard of warnings and errors from Google’s activity.

I remembered a few years back to some time at sacbee.com when one of the designers demonstrated Apache’s server side includes weren’t limited to including a page snippet or executing a CGI script, but included conditional logic. That’s precisely what I was after in this case.

I set an environment variable in my local Apache configuration then wrapped the conditional logic around my AdWords call and the Analytics JavaScript. In 10 minutes, I had a nice, quick solution to keeping the Web Inspector clean of anything other than my own errors.

So, what does this look like? My Apache directive is very simple. You’ll need both mod_include and mod_env enabled.

Then, on my pages, I do something like this:

When that NoAds environment variable is set, that file won’t be included. In production, it will be. My next approach on this will be to use different versions of jQuery based on environment. I can use a developer friendly version for my local development and use Google’s hosted jQuery in production. What’s really nice about this is with Apache 2.2’s chained handlers, I can use the same logic regardless of whatever’s building the page first, be it Rails, Template Toolkit or PHP.

← Previous Next →