Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shouldn't we use <noscript> element?

I found some good cons here:

  • The noscript element only detects whether the browser has JavaScript enabled or not. If JavaScript is disabled in the Firewall rather than in the browser then the JavaScript will not run and the content of the noscript element will not be displayed.

  • Many scripts are dependent on a specific feature or features of the language being supported in order for them to be able to run (for example document.getElementById). Where the required features are not supported the JavaScript is unable to run but since JavaScript itself is supported the noscript content will not be displayed.

  • The most useful place to use the noscript element is in the head of the page where it would be able to selectively determine what stylesheet and meta elements get applied to the page as the page is loading rather than having to wait until the page is loaded. Unfortunately the noscript element is only valid within the body of the page and so cannot be used in the head.

  • The noscript element is a block level element and therefore can only be used to display entire blocks of content when JavaScript is disabled. It cannot be used inline.

  • Ideally, web pages should use HTML for the content, CSS for the appearance, and JavaScript for the behavior. Using the noscript element is applying a behavior from within the HTML rather than applying it from JavaScript.

Source: http://javascript.about.com/od/reference/a/noscriptnomore.htm

I very much agree on last point. Is there a way to make and add an external <noscript> file? Should we place <noscript> in the <head>?

like image 897
Jitendra Vyas Avatar asked Jan 31 '10 03:01

Jitendra Vyas


People also ask

Should I use noscript tag?

Why should we use <noscript> element in JavaScript? To find whether the browser supports JavaScript or not, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display an alternate text message.

What is the purpose of the noscript element?

<noscript>: The Noscript element The <noscript> HTML element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser. Metadata content, flow content, phrasing content.

Does noscript works even with browsers that don't recognize the noscript tag?

The HTML <noscript> tag is used to handle the browsers which do recognize <script> tag but do not support scripting.

Where should I put noscript tag?

In HTML5 the <noscript> tag can be placed in the <head> and <body> elements. In HTML4 it can be used only in the <body> element.


1 Answers

It's better to have the default be non-javascript, and then let a javascript code overwrite with a javascript enabled page. Doesn't have to be much. Can just be a display:none; block, which is then set to display:block; by javascript, and vice versa for the non-js page.

like image 155
Tor Valamo Avatar answered Sep 21 '22 09:09

Tor Valamo