3 ms·
No. Many sites have a style like "display: none" on body element, to hide content until JS is loaded. But of course they have content in HTML for search engines
by codedokode 7y ago
No. Many sites have a style like "display: none" on body element, to hide content until JS is loaded. But of course they have content in HTML for search engines optimization. So they show content to Google robot instantly, but the human user has to wait.
Google also uses this trick in search results if I remember correctly.
- chrismorgan 7y agoExactly. Here’s an example I encountered today: https://status.digitalocean.com/ https://status.digitalocean.com/, all the content is in a div that is affected by `.layout-content.status.status-index { opacity: 0 }`. JavaScript code then sets `.style.opacity = 1` on the element to undo that. This is a bad technique. If you really want that effect, something friendlier would be this in the head of the document: <script>document.documentElement.className+=' js'</script> … then prefix that earlier selector with `.js`. Or another approach: remove the `opacity: 0` from the stylesheet, and immediately inside the element to be hidden while loading, add <script>document.currentScript.parentNode.style.opacity=0</script> Remember that external JS is never guaranteed to load; even on normal people’s computers, networks are not reliable and even first-party resources can fail to load, though it’s ones on a different origin that are the least reliable.