After adding an embedded Gist in my WP post, all I see when fetching it through REST API is the embed code, meaning <script src="https://gist.github.com/username/b5f6f2d0xxxxxxxdf9c90cbede0e.js"></script>
.
There are solutions to properly render an embedded Gist in WordPress but these solutions work on a WordPress site, not on a non-WP site merely fetching posts from WP.
Any idea how to solve this issue?
EDIT:
As per this suggestion, I tried to extract the script
tag from the post and re-inject it into the DOM. But, it still doesn't work. Actually even when simply loading my Gist script into a variable then injecting the content into the DOM, it doesn't work. Yet it works with any other script, for example this:
const tag = document.createElement('script');
tag.src = 'https://my-site.com/test.js';
document.querySelector('body').prepend(tag);
But the exact same snippet using instead my Gist URL fails to execute.
Why don't Gist scripts execute when injected into the DOM?