Progressive enhancement of NOSCRIPT tags containing images

For the 2nd of our 4 part plan to solve the problem of responsive images using current browser standards, we need to put our noscript textContent polyfill to work. What better than to refactor the seminal responsive design original from A List Apart by Ethan Marcotte.

To start with, all we do is move the 6 character images into noscript tags, add our polyfill ot the bottom of the body and run a small amount of cross browser script to append the content of the noscript tag after itself. You can see the results here.


<script type="text/javascript" src="js/noscript.min.js"></script>
<script type="text/javascript">
var tags = document.getElementsByTagName("noscript");
for (var i=0, len=tags.length; i<len; i++) {
  var tag = tags[i];
  tag.insertAdjacentHTML('afterend', tag.textContent);
}
</script>


 
This provides us with the hook we need to dynamically modify image paths before they are added to the DOM.

Advertisements
Progressive enhancement of NOSCRIPT tags containing images

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s