Including CSS files in HEAD based on page content

You can’t predict if something will include your box further down the line, so to do it “the right way”, you’ll need to add your CSS/JS early.

The not-so-right way could be to add output buffering and analyze the output to see if your box got included somewhere, and then add your HTML to the head of the document. It’s not clean, and I’d make it optional (and disabled in the default mode so the user has to activate it) and add some explanation as it can get confusing when you wonder why something does/does not work on different pages, and it’s often a pain to debug these things if you’re not aware of them.