Although this may have been the best answer at the time, I think it is better now.
For a given value, for example. https://gist.github.com/anonymous/5446951 you can access the JSON object containing the HTML markup and CSS URI for Gist at https://gist.github.com/anonymous/5446989.json - it looks something like So:
{ "description": ..., "public":true, ... "div": <HTML code>, "stylesheet": <URI of CSS file> }
In fact, you can get this data as JSONP: https://gist.github.com/anonymous/5446989.json?callback=callback12345
So, to dynamically load Gist without iframe:
function loadGist(element, gistId) { var callbackName = "gist_callback"; window[callbackName] = function (gistData) { delete window[callbackName]; var html = '<link rel="stylesheet" href="' + escapeHtml(gistData.stylesheet) + '"></link>'; html += gistData.div; element.innerHTML = html; script.parentNode.removeChild(script); }; var script = document.createElement("script"); script.setAttribute("src", "https://gist.github.com/" + gistId + ".json?callback=" + callbackName); document.body.appendChild(script); }
source share