Is the content uploaded / stylized / parsed in the <noscript> tag even when JavaScript is enabled?

For my site, I display a <div> within the <noscript> tag.

In the DIV, I have an image.

Quick example:

<noscript> <img src="logo-sm.png" alt="Site Logo"/> </noscript> 

If JavaScript is enabled, is this image still loaded and CSS styles apply to it? What about DOM event listeners? I am wondering if there will be a lot of external content (whether images, video, audio, etc.) that will affect page loading for people who really allow JavaScript in advance.

EDIT:

By the way, I do not have this site on the Internet. I am using XAMPP to view in Chrome Canary.

+6
source share
4 answers

If JavaScript is enabled, is this image still loaded and CSS styles apply to it?

Depends on browser implementations. Most modern browsers support the use of the <noscript> , but in some cases <noscript> may even work if <script> not executed.

However, if <noscript> is executed (I know), the css styles will be applied to the elements on the page as they are added to the DOM

What about DOM event listeners?

If the script is enabled in the browser and you are serving the <noscript> content, then the content should match so that it does not cause parry errors. See more details

I would advise you not to use <noscripts> , because the manual says:

The noscript element is a dumb tool. Sometimes scripts may be included, but for some reason, the script page may fail. For this reason, it is generally best to avoid using noscript and instead create a script to change the page from an unencrypted page to a script page on the fly

Hope that helps :)

+2
source

Answers:

  • The image does not appear as a resource in the console, so it does not load.
  • Chrome quotes the innerHTML of the noscript tag, making it plain text.
+2
source

If Javascript is enabled, there is no reason the code should work. Noscript tags are for browsers / users without JS enabled. If javascript is disabled, the image will be displayed differently, it will just take time to load, but it just does not display.

0
source

Content inside the <noscript> element will be displayed if scripts are not supported or disabled in the users browser.

-2
source

Source: https://habr.com/ru/post/951774/


All Articles