3 ms·
Exactly. 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 chrismorgan 7y ago
Exactly. 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.