Card & card# classes only injected separately now?

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:

  1. This is static info / known in advance, so it’s unnecessary to inject this only afterwards rather than generate it at the very beginning.
  2. For unsupported uses of JavaScript, this introduces unnecessary complexity.
  3. 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.]

It’s probably a side effect of some other change. You have the skills to investigate this. The relevant code is in ts/reviewer - please figure out why it’s occurring, and if possible, propose a solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.