How to embed a gist into github pages.

1. Add script file.

Add gist embedding script into your github pages.

<script src="https://gist.github.com/Albert-W/e37d1c4fa30c430c37d7b1b1fe9b60d8.js"></script>

2. For asynchronously-loaded page

The embedding script will execute document.write function. If you are using asynchronously-loaded one error will occur. (出于浏览器的安全机制,浏览器是会禁止异步加载过来的js执行document写入操作的。)

 Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

In order to solve this problem, Iframe is required. A demo is giving as follow.