Currently, I am working on a blog post that will showcase various HTML5/Javascript animations through multiple <iframe>
sections. These animations utilize methods such as requestAnimationFrame()
and/or setInterval()
. Due to limitations within the blogging platform, using iframes is my only option to incorporate custom Javascript.
Given that these animations are fairly resource-intensive, I am curious to know if there exists a way for the Javascript inside the iframe to detect when it's not in view and pause execution until it's visible again. Is it possible to implement such functionality?
(P.S. The domain hosting the iframe differs from that of the parent document, suggesting that issues related to the same-origin policy could make achieving this feature more challenging or even impossible.)