Monday, July 21, 2008

Linking dynamic CSS and JS files

A long while back I discovered a really smooth trick for creating server-side dynamic CSS and JavaScript files.

The web server takes care of all the work. Instead of this:

<link rel="stylesheet" href="/cssjs/css_pmtool.css" type="text/css" />
<SCRIPT langauge="JavaScript" src="cssjs/digit.js" type="text/javascript"></SCRIPT>

Do this:

<link rel="stylesheet" href="/cssjs/css_pmtool.cfm" type="text/css" />
<SCRIPT langauge="JavaScript" src="cssjs/digit.js" type="text/javascript"></SCRIPT>

And don't forget to put a content header in the CSS file. If I recall it made a difference. But didn't make any difference in the JS files.

<cfcontent type="text/css; charset=ISO-8859-1">

.