Mobile app version of vmapp.org
Login or Join
Angie530

: Are there any good reasons to avoid using the noscript tag in an HTML5 header? I need an efficient and aesthetically-pleasing way to gracefully degrade site appearance for users with Javascript

@Angie530

Posted in: #Headers #Html #Noscript

I need an efficient and aesthetically-pleasing way to gracefully degrade site appearance for users with Javascript disabled and, while I am not aware of any problem with adding a link to an alternative stylesheet wrapped in noscript tags in the document header w/HTML5, I figured it couldn't hurt to ask before going that route.

Update: Example document to demonstrate undesirable behavior when using JS to hide elements

This document reliably shows a red blink while the browser repaints the window contents when I test with a hard refresh in Internet Explorer 8.0 (note that I had to add a fairly large image to get IE to exhibit this behavior - I expect that this will appear in IE whenever resources are low).

<html>
<head>
<title>See the blink?</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$('#blinky').css('display','none');
});
</script>
<style type="text/css">
body {
background-color:#000000;
}
div#blinky {
background-color:#FF0000;
position:absolute;
height:100%;
width:100%;
}
</style>
</head>
<body>
<img src="http://apod.nasa.gov/apod/image/9712/orionfull_jcc_big.jpg" height="1" width="1" />
<div id="blinky">
<h1>Did you see it?</h1>
</div>
</body>
</html>


I refuse to upgrade until I absolutely have to, so I believe my somewhat-underpowered desktop is representative of the lowest common denominator of the user experience; I can't guarantee that you'll be able to duplicate on a high-end machine with ample resources available but you're welcome to give it a try to see what I mean.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

In general it's better to use progressive enhancement rather than graceful degradation. This means essentially starting with the content as if the user has no scripting, then using Javascript to enhance the page.

For example, you might start with a link/button that goes somewhere or submits a form. Then you add Javascript that prevents naivgation/submission and does something else instead.

For your specific case, I can't think of a good reason to add a stylesheet in noscript tags. Why not add the styles to your main stylesheet? If there is a clash of styles, I would start with the noscript ones applied then use Javascript to add a single class/ID on a parent element which changes the styles.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme