· Hahaxiong
Zero-Cost Lazy Giscus Comments with Live Theme Sync
For developer and AI research blogs, pairing IntersectionObserver + postMessage keeps Giscus completely free of performance or database overhead:
- Never load
giscus.app/client.json initial page paint—inject it only when the reader scrolls within280pxof the comment container. - Listen for theme toggles and dispatch
postMessage({ giscus: { setConfig: { theme } } }, 'https://giscus.app')so light/dark mode switches instantaneously without reloading the iframe.