0

How can i use this

document.getElementById("loader").style.display = "none";

when javascript is disabled on client browser? I added this w3school loading animation tutorial unto my site but it keep rotating when javascript is disabled on client browser and blocking the

<noscript>Sorry, your browser does not support JavaScript!</noscript>

Should i just create an image and just use z-index: 9999; to declare Sorry, your browser does not support JavaScript! or are they any alternative?

I created a demo page of it what it look like when you have javascript disabled and how it infinitely just rotating and blocking <noscript>. demo page here

Emma Marshall
  • 354
  • 1
  • 12
  • 1
    Does this answer your question? [Embedding extra styles with noscript](https://stackoverflow.com/questions/218162/embedding-extra-styles-with-noscript) – DarkBee Feb 18 '22 at 09:24

2 Answers2

3

You can set it to display: none; by default, and show it through javascript, so if javascript is disabled, it would not show

rosmak
  • 545
  • 1
  • 12
  • Thanks this perfectly work also i set the whole HTML content too with `display: none; ` cuz whole content is run by `setTimeout` to show up so no javascript they won't see a thing except the ` – Emma Marshall Feb 18 '22 at 09:43
3

Just add CSS into noscript tag:

<noscript>
  <style type="text/css">
    selector {
      display: none;
    }
  </style>
</noscript>

If you do the opposite by accessing styling through JS, you will encounter flickering / showing unnecessary elements before script is loaded and executed.

Samuli Hakoniemi
  • 18,740
  • 1
  • 61
  • 74