Tuesday, May 27, 2014

User friendliness and SEO optimization for clients without JS using <noscript>, <meta>

The following is a simple HTML hack to really help with detecting clients without JavaScript enabled or supported and serve them better content accordingly:

In the <head>, add this code:
<noscript><meta http-equiv="refresh" content="0; url=www.example.com/no-js-version" /></noscript>
The URL can be any of your choosing, and it matters none what it is. It is just meant to point to a version that does not require JavaScript. This is best placed as the first tag after the <meta charset="utf-8" /> element in the <head>.

There is a caveat to this: it only validates as HTML5. This means nothing to modern browsers, but it could provide potential issues if compatibility with older browsers (e.g. IE8 or earlier) is needed.

No comments:

Post a Comment