At some point*, it seems that Anki Desktop started to inject the applying card
& card#
classes into the body tag (document.body.className
) only after a card’s/site’s HTML has already been generated, as through by a script running only afterwards.
Adding for instance…
<script>
console.log(document.body.className)
window.addEventListener("load", _ => {
console.log(document.body.className)
})
</script>
… to the frontside of the Basic template logs for me (ad74a014/git):
isLin nightMode night_mode reduce-motion fancy
card card1 isLin nightMode night_mode reduce-motion fancy
This only seems to reliably happen when the card is complex enough and/or when Anki hasn’t yet shown/cached the generated HTML, such as immediately after being just started.
Most users will not care about this, but:
- This is static info / known in advance, so it’s unnecessary to inject this only afterwards rather than generate it at the very beginning.
- For unsupported uses of JavaScript, this introduces unnecessary complexity.
- For styling using these classes, there is a brief moment where this may introduce jumps in rendering.
[*: I don’t know which version since I don’t use Anki Desktop for reviewing that often.]