JSFiddle - React, Tailwind, and code Playground

HTML

<pre id="log"></pre>

JavaScript

function loadScript( source ) {

  return new Promise( (resolve, reject) => {

    const iframe = document.createElement( 'iframe' );
    iframe.style = "display:none"//"opacity:0;z-index:-999;position:fixed";
    iframe.src = "about:blank";
    document.body.append( iframe );

    const doc = iframe.contentDocument;
    doc.write( `<script src="${ source }" sandbox="allow-scripts"><\/script>` );
    doc.close();

    iframe.contentWindow.onload = (evt) => {
      iframe.remove();
      resolve( doc );
    };
    iframe.contentWindow.onerror = (evt) => {
      iframe.remove();
      reject( evt );
    };

  } );
  
}

loadScript( "https://gist.github.com/ayushn21/e6f101f2e28ae609446b9aec95d4e2da.js" )
  .then( doc => {
    const elem = doc.getElementById( 'gist40148058' );
    log.textContent = elem.textContent;
  } )
  .catch( console.error );