I solved this by building Web Components out of them. Basically the HTML needs just a custom template tag, which includes a script with the JSON-LD payload. The component corresponding to the template, initializes itself based on that data. See here for an example: https://releases.bruta.link/releases/2026/June/21

Granted, all of this is not for SEO purposes, but part of the ActivityPub ecosystem, which also uses JSON-LD for data encoding.