<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Understanding and solving the JavaScript/CSS entanglement phenomenon</title>
	<atom:link href="http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: joe</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247327</link>
		<dc:creator>joe</dc:creator>
		<pubDate>Sat, 17 Feb 2007 02:51:39 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247327</guid>
		<description>I prefer not supporting non-js browsers.  F &#039;em.</description>
		<content:encoded><![CDATA[<p>I prefer not supporting non-js browsers.  F &#8216;em.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: noname</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247322</link>
		<dc:creator>noname</dc:creator>
		<pubDate>Fri, 16 Feb 2007 23:41:29 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247322</guid>
		<description>I&#039;m using this method to switch skins</description>
		<content:encoded><![CDATA[<p>I&#8217;m using this method to switch skins</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cedsav</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247319</link>
		<dc:creator>cedsav</dc:creator>
		<pubDate>Fri, 16 Feb 2007 19:04:31 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247319</guid>
		<description>Want another method (not necessarily better) ? 
Add the js only stylesheet as an alternate stylesheet. Then use javascript to enable it. More about it here (posted in April 2005:-) :
http://www.formassembly.com/blog/javascript-enabled-stylesheets/</description>
		<content:encoded><![CDATA[<p>Want another method (not necessarily better) ?<br />
Add the js only stylesheet as an alternate stylesheet. Then use javascript to enable it. More about it here (posted in April 2005:-) :<br />
<a href="http://www.formassembly.com/blog/javascript-enabled-stylesheets/" rel="nofollow">http://www.formassembly.com/blog/javascript-enabled-stylesheets/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247315</link>
		<dc:creator>michael</dc:creator>
		<pubDate>Fri, 16 Feb 2007 16:42:04 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247315</guid>
		<description>I do this all the time. coupled with Dean&#039;s window.onload solution it looks something like:
&lt;code&gt;
var dynPage = {
	DOMavailable : null,
	init:function() {
		// quit if this function has already been called
		if (arguments.callee.done) return;
		
		// flag this function so we don&#039;t do the same thing twice
		arguments.callee.done = true;
		
		// kill the timer
		if (_timer) {
			clearInterval(_timer);
			_timer = null;
		}

		dynPage.DOMavailable = true;
		dynPage.enable();

		// load the other functions
	},
	
	enable:function() {
		document.body.className += &#039; dynamic&#039;;
	}
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I do this all the time. coupled with Dean&#8217;s window.onload solution it looks something like:<br />
<code><br />
var dynPage = {<br />
	DOMavailable : null,<br />
	init:function() {<br />
		// quit if this function has already been called<br />
		if (arguments.callee.done) return;</p>
<p>		// flag this function so we don't do the same thing twice<br />
		arguments.callee.done = true;</p>
<p>		// kill the timer<br />
		if (_timer) {<br />
			clearInterval(_timer);<br />
			_timer = null;<br />
		}</p>
<p>		dynPage.DOMavailable = true;<br />
		dynPage.enable();</p>
<p>		// load the other functions<br />
	},</p>
<p>	enable:function() {<br />
		document.body.className += ' dynamic';<br />
	}<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Frueh</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247313</link>
		<dc:creator>Peter Frueh</dc:creator>
		<pubDate>Fri, 16 Feb 2007 16:07:05 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247313</guid>
		<description>This situation is one of the few exceptions where document.write is really useful.  I like to set up the HTML and CSS as if it&#039;s all the browser can handle, and then document.write an override stylesheet with JS -- which usually is just a bunch of #element { display:none; } statements.  It looks like this:

IN HEAD (all unobtrusive external files):
1. CSS stylesheet for JS-disabled browsers
2. JS that document.writes an override stylesheet
3. JS for rearranging/behavior

IN BODY:
Clean (X)HTML markup for JS-disabled browsers/search engines</description>
		<content:encoded><![CDATA[<p>This situation is one of the few exceptions where document.write is really useful.  I like to set up the HTML and CSS as if it&#8217;s all the browser can handle, and then document.write an override stylesheet with JS &#8212; which usually is just a bunch of #element { display:none; } statements.  It looks like this:</p>
<p>IN HEAD (all unobtrusive external files):<br />
1. CSS stylesheet for JS-disabled browsers<br />
2. JS that document.writes an override stylesheet<br />
3. JS for rearranging/behavior</p>
<p>IN BODY:<br />
Clean (X)HTML markup for JS-disabled browsers/search engines</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Schiller</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247312</link>
		<dc:creator>Scott Schiller</dc:creator>
		<pubDate>Fri, 16 Feb 2007 16:05:35 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247312</guid>
		<description>You can also append this to the HEAD within the first nested script block pretty reliably, eg. getElementsByTagName(&#039;head&#039;)[0].className = .. and then match with CSS, head.isIE div {}, and so on. I believe someone from MSFT published a related article on filtering (as Mark Wubben mentioned) via class name this way last year. It&#039;s pretty effective.</description>
		<content:encoded><![CDATA[<p>You can also append this to the HEAD within the first nested script block pretty reliably, eg. getElementsByTagName(&#8216;head&#8217;)[0].className = .. and then match with CSS, head.isIE div {}, and so on. I believe someone from MSFT published a related article on filtering (as Mark Wubben mentioned) via class name this way last year. It&#8217;s pretty effective.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ara Pehlivanian</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247311</link>
		<dc:creator>Ara Pehlivanian</dc:creator>
		<pubDate>Fri, 16 Feb 2007 15:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247311</guid>
		<description>&lt;strong&gt;Chris Heilmann&lt;/strong&gt;: I guess I missed that post. Interesting how people come out of the woodwork with solutions that are similar (if not identical) that they probably came to on their own :-).

&lt;strong&gt;Mark Kahn&lt;/strong&gt;: I&#039;m leaning more towards that approach since it allows for the storage of js only css in a separate file and removes the need for prefixing every rule with &quot;hasJS&quot;.</description>
		<content:encoded><![CDATA[<p><strong>Chris Heilmann</strong>: I guess I missed that post. Interesting how people come out of the woodwork with solutions that are similar (if not identical) that they probably came to on their own :-).</p>
<p><strong>Mark Kahn</strong>: I&#8217;m leaning more towards that approach since it allows for the storage of js only css in a separate file and removes the need for prefixing every rule with &#8220;hasJS&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247307</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Fri, 16 Feb 2007 14:08:33 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247307</guid>
		<description>I use the same tactics as described here since a while back. It seems as obvious as the kind of test you run to detect browser abilities:

really short example:
&lt;code&gt;
if(!document.getElementById) return false; // and thus kill all the script
if($(&#039;hideMe&#039;)) $(hideMe).className += &quot; hidden&quot;; // hide choosen elem.
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I use the same tactics as described here since a while back. It seems as obvious as the kind of test you run to detect browser abilities:</p>
<p>really short example:<br />
<code><br />
if(!document.getElementById) return false; // and thus kill all the script<br />
if($('hideMe')) $(hideMe).className += " hidden"; // hide choosen elem.<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dashifen</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247306</link>
		<dc:creator>Dashifen</dc:creator>
		<pubDate>Fri, 16 Feb 2007 13:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247306</guid>
		<description>I&#039;ve used a similar trick to hide and show interfaces which require javascript.  Create a .show CSS selector that has a default rule of display: none; Then, use javascript to include a second, separate .css file with two rules:   .show { display: block; } and .hide { display: none; }.  Then, on pages which need to hide a whole portion of code from non-javascript browsers, put the javascript-requiring code in the .show element (which will be hidden if javascript doesn&#039;t include the &quot;extra&quot; .css file) and messages and/or other interface elements within the .hide element (shown unless javascript hides it).  Essentially the same concept as above, just executed somewhat differently.

Excellent post.  Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;ve used a similar trick to hide and show interfaces which require javascript.  Create a .show CSS selector that has a default rule of display: none; Then, use javascript to include a second, separate .css file with two rules:   .show { display: block; } and .hide { display: none; }.  Then, on pages which need to hide a whole portion of code from non-javascript browsers, put the javascript-requiring code in the .show element (which will be hidden if javascript doesn&#8217;t include the &#8220;extra&#8221; .css file) and messages and/or other interface elements within the .hide element (shown unless javascript hides it).  Essentially the same concept as above, just executed somewhat differently.</p>
<p>Excellent post.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Kahn</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247303</link>
		<dc:creator>Mark Kahn</dc:creator>
		<pubDate>Fri, 16 Feb 2007 12:46:48 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247303</guid>
		<description>Um...let&#039;s try this again...

[noscript]
	[link rel=&quot;stylesheet&quot; href=&quot;my.css&quot; type=&quot;text/css&quot;]
[/noscript]
[script]
	var css = document.createElement(&#039;LINK&#039;); 
	// set attributes, append to head
[/script]</description>
		<content:encoded><![CDATA[<p>Um&#8230;let&#8217;s try this again&#8230;</p>
<p>[noscript]<br />
	[link rel="stylesheet" href="my.css" type="text/css"]<br />
[/noscript]<br />
[script]<br />
	var css = document.createElement(&#8216;LINK&#8217;);<br />
	// set attributes, append to head<br />
[/script]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Kahn</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247302</link>
		<dc:creator>Mark Kahn</dc:creator>
		<pubDate>Fri, 16 Feb 2007 12:45:54 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247302</guid>
		<description>My personal preference is to do this:


	


	var css = document.createElement(&#039;LINK&#039;); 
	// set attributes, append to head


That way I can just manage two seperate stylesheets which usually @import a third common one.</description>
		<content:encoded><![CDATA[<p>My personal preference is to do this:</p>
<p>	var css = document.createElement(&#8216;LINK&#8217;);<br />
	// set attributes, append to head</p>
<p>That way I can just manage two seperate stylesheets which usually @import a third common one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kjell</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247299</link>
		<dc:creator>Kjell</dc:creator>
		<pubDate>Fri, 16 Feb 2007 11:24:50 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247299</guid>
		<description>yup. .. i am used these tactics and even more: Besides hiding/showing JS related elements, i also save the non-js-user from downloading my javascript files - since he is not going to parse them anyways. ;)
This saves traffic and speeds up the page loads. Once that is handled i try shaping the load precedure by sorting out what scripts are needed first and where.. aka. intelligent script loading.</description>
		<content:encoded><![CDATA[<p>yup. .. i am used these tactics and even more: Besides hiding/showing JS related elements, i also save the non-js-user from downloading my javascript files &#8211; since he is not going to parse them anyways. ;)<br />
This saves traffic and speeds up the page loads. Once that is handled i try shaping the load precedure by sorting out what scripts are needed first and where.. aka. intelligent script loading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247297</link>
		<dc:creator>Edwin</dc:creator>
		<pubDate>Fri, 16 Feb 2007 09:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247297</guid>
		<description>I&#039;m using this for my current project. Works great. Except you might initially see the non-js version for a fraction of a second (even when called onDomReady).

You also have to use a &quot;addClass&quot;-function, because the body might already have one or more classes.</description>
		<content:encoded><![CDATA[<p>I&#8217;m using this for my current project. Works great. Except you might initially see the non-js version for a fraction of a second (even when called onDomReady).</p>
<p>You also have to use a &#8220;addClass&#8221;-function, because the body might already have one or more classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Giammarchi</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247295</link>
		<dc:creator>Andrea Giammarchi</dc:creator>
		<pubDate>Fri, 16 Feb 2007 09:02:24 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247295</guid>
		<description>I think updated solution is better, without script inside the body, just &quot;classing&quot; the documentElement. Simple and clear.</description>
		<content:encoded><![CDATA[<p>I think updated solution is better, without script inside the body, just &#8220;classing&#8221; the documentElement. Simple and clear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Wubben</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247294</link>
		<dc:creator>Mark Wubben</dc:creator>
		<pubDate>Fri, 16 Feb 2007 08:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247294</guid>
		<description>You can do the same thing with browser names and versions. This lets you specify CSS workarounds  for the JavaScript version without relying on CSS hacks.

The code posted does have a bug though: by simply adding &quot;hasJS&quot; to the class name, it will affect classes already there. So &quot;foo&quot; becomes &quot;foohasJS&quot;.</description>
		<content:encoded><![CDATA[<p>You can do the same thing with browser names and versions. This lets you specify CSS workarounds  for the JavaScript version without relying on CSS hacks.</p>
<p>The code posted does have a bug though: by simply adding &#8220;hasJS&#8221; to the class name, it will affect classes already there. So &#8220;foo&#8221; becomes &#8220;foohasJS&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wiktor</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247293</link>
		<dc:creator>Wiktor</dc:creator>
		<pubDate>Fri, 16 Feb 2007 08:53:09 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247293</guid>
		<description>I found this trick in Drupal, in /misc/drupal.js.
&lt;code&gt;
// Global Killswitch on the  element
if (isJsEnabled()) {
  document.documentElement.className = &#039;js&#039;;
}
&lt;/code&gt;
The code is taken from 4.7.6.</description>
		<content:encoded><![CDATA[<p>I found this trick in Drupal, in /misc/drupal.js.<br />
<code><br />
// Global Killswitch on the  element<br />
if (isJsEnabled()) {<br />
  document.documentElement.className = 'js';<br />
}<br />
</code><br />
The code is taken from 4.7.6.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://ajaxian.com/archives/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1#comment-247292</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Fri, 16 Feb 2007 08:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2126#comment-247292</guid>
		<description>wow, very clever ^^

I think I will use that in the future quite often ;)</description>
		<content:encoded><![CDATA[<p>wow, very clever ^^</p>
<p>I think I will use that in the future quite often ;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

