luceos You're absolutely right. What was being attempted in the example code was to make an existing function within the project work properly instead of creating a new one.
For instance, in this example this code, I managed the rendering not only during the first visit but also on every route/page change and even within different comments inside a discussion.
A similar approach could achieve this as well. However, the example code provided by @seodevse made me feel like such an approach might not be necessary in this case
@luceos I guess I'm starting to improve myself, right? 😄