Search code examples
javascriptcross-browsergraceful-degradation

<noscript> or something else


I have a site that relies heavily on JavaScript and uses jQuery throughout.

I'm not going to attempt to make the site work for those who don't have JavaScript enabled.

However, I would like to show a banner at the top of the page which tells them the site is intended for use with JavaScript enabled and perhaps a modern browser, etc.

I was thinking of just putting a PHP include on all pages that contains a <noscript> with the banner inside that. Is this is good approach or is there a better way?


Solution

  • <noscript> is the way to go.

    You should also provide links to other, better browsers in the <noscript> tag if you can detect that's a browser without JavaScript.

    If you wish to be more drastic about it, start with the markup <body class="nojs"> and, onload remove that class with JavaScript.

    You could then have body.nojs #wrapper { display: none; }, body.nojs #notice { display: block } in your CSS.