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
After pondering for many days and changing my code back and forth, I think I have clearer picture now and would like to share my two cents worth on the subject before I forget.
show non-js content
vs
Depending on the situation, there are three cases for consideration:
JavaScript disabled
element appears immediately, non-js content is
shown element appears immediately, non-js content is shown
JavaScript enabled
- Content in
element does not appear at all, js content shown
- Content in
element may momentarily appear before being hidden, js
content shown
For this case, using
element is advantageous.
Case 2 - If required script is from external (third-party) source, but hiding of element is done with inline script
JavaScript disabled
- Content in
element appears immediately, non-js content is
shown
- Content in
element appears immediately, non-js content is shown
JavaScript enabled but required script is blocked
- Content in
element does not appear at all, nothing is shown!
- Content in
element may momentarily appear before being hidden, nothing is shown!
JavaScript enabled and required script is received
- Content in
element does not appear at all, js content shown
- Content in
element may momentarily appear before being hidden, js
content shown
For this case, using
element is advantageous.
Case 3 - If required script hides the element
JavaScript disabled
- Content in
element appears immediately, non-js content is
shown
- Content in
element appears immediately, non-js content is shown
JavaScript enabled but required script is blocked
- Content in
element does not appear at all, nothing is shown!
- Content in
element appears, non-js content is shown
JavaScript enabled and required script is received
- Content in
element does not appear at all, js content shown
- Content in
element may momentarily appear before being hidden, js
content shown
For this case, using element is advantageous.
In summary
Use
element if rendering of the HTML content depends on third-party scripts or if the required script is inline. Else, use element and make sure that the required script contains:
document.getElementById('noscript').style.display='none';
- 热议问题