Forum Moderators: open

Message Too Old, No Replies

How to use no-js in the correct way?

         

toplisek

11:47 am on Feb 2, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I like to put
for IE 9 and lower:
<!--[if IE 9]><!--> <html class="ie no-js"><!--<![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js"><!--<![endif]-->

What are consequences inside Bootstrap V3 in this case?

lucy24

4:47 pm on Feb 2, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



[if gt IE 9]

Since MSIE 10 dropped support for Conditional Comments*, this line will never be read by anyone anywhere.


* Apparently on the grounds that MSIE's behavior has become similar enough to that of a real browser that CCs are no longer needed.

dannyboy

2:46 am on Feb 28, 2015 (gmt 0)

10+ Year Member



You don't need the conditional comments. You'd use it like this:

<html class="no-js">


Then have something like this within your <head> tag:
<script type="text/javascript">document.documentElement.className='js'</script>


You'd then use .no-js or .js within your CSS stylesheet as such:


.slideshow-slide {
display: none; /* hide slides by default */
}
.no-js .slideshow-slide {
display: block; /* JavaScript is disabled, so show all slides */
}


I typically never use .js within the CSS. 99% of folks will have JavaScript enabled, so the default styles assume .js is active. I only use .no-js when needed.

If you use Modernizr, you don't have to do the .no-js to .js swap. It does it automatically.

toplisek

3:07 pm on Mar 3, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you for your reply.