Can I run HTML files directly from GitHub, instead of just viewing their source?

Can I run HTML files directly from GitHub, instead of just viewing their source?

If I have a .html file in a GitHub repository, e.g. for running a a set of JavaScript tests, is there any way I can view that page directly—thus running the tests?
For example, could I somehow actually see the test results that would be produced by the jQuery test suite, without downloading or cloning the repo to my local drive and running them there?
I know this would basically put GitHub in the static content hosting business, but then again, they just have to change their mime-type from text/plain to text/html.


Solution 1:

You might want to use It supports GitHub, Bitbucket, Gitlab and GitHub gists.



In your case .html extension


Development (throttled)[user]/[repository]/[branch]/[filename.ext]

Production (CDN)[user]/[repository]/[branch]/[filename.ext]

In your case .html extension also supports other services:




Development (throttled)[user]/[repository]/raw/[branch]/[filename.ext]

Production (CDN)[user]/[repository]/raw/[branch]/[filename.ext]




Development (throttled)[user]/[repository]/raw/[branch]/[filename.ext]

Production (CDN)[user]/[repository]/raw/[branch]/[filename.ext]

GitHub gists



Development (throttled)[user]/[gist]/raw/[revision]/[filename.ext]

Production (CDN)[user]/[gist]/raw/[revision]/[filename.ext]

Update: rawgit was discontinued

Solution 2:

There is a new tool called GitHub HTML Preview, which does exactly what you want. Just prepend to the URL of any HTML file, e.g.

Note: This tool is actually a page and is not affiliated with github as a company.

Solution 3:

To piggyback on @niutech’s answer, you can make a very simple bookmark snippet.
Using Chrome, though it works similarly with other browsers

  1. Right click your bookmark bar
  2. Click Add File
  3. Name it something like Github HTML
  4. For the URL type javascript:top.location=""+document.URL
  5. When you’re on a github file view page (not click the bookmark link and you’re golden.

Solution 4:

You can either branch gh-pages to run your code or try this extension (Chrome, Firefox):

If what you need are tests, you could embed your JS files into:

Solution 5:

I had the same problem for my project Ratio.js and here’s what I did.

Problem: prevents files from rendering/executing when the source is viewed by setting the content type/MIME to plain text.

Have a web page import the files.


Use or to create a webpage online then save it.
Navigate to your file in and click the ‘raw’ button to get the direct link to the file.
From there, import the file using the appropriate tag and attribute.

        <link rel="stylesheet" href="" type="text/css" media="screen" />
        <h1 id="qunit-header">QUnit example</h1>
        <h2 id="qunit-banner"></h2>
        <div id="qunit-testrunner-toolbar"></div>
        <h2 id="qunit-userAgent"></h2>
        <ol id="qunit-tests"></ol>
        <div id="qunit-fixture">test markup, will be hidden</div>
        <script src=""></script>
        <script type="text/javascript" src=""></script>  
        <script type="text/javascript" src=""></script>  
        <script type="text/javascript" src=""></script>  

Live Demo:

Note: Note for you can get direct access to the result page by adding show to the end of the url.
Like so:

Or….you could create a project page and render your HTML files from there.
You can create a project page at

Once created you can then access the link through http://*accountName**projectName*/

Solution 6:

Here is a little Greasemonkey script that will add a CDN button to html pages on github

Target page will be of the form:

// ==UserScript==
// @name
// @namespace
// @include*/blob/*.html
// @version     1
// @grant       none
// ==/UserScript==

var buttonGroup = $(".meta .actions .button-group");
var raw = buttonGroup.find("#raw-url");
var cdn = raw.clone();
cdn.attr("id", "cdn-url");
cdn.attr("href", "" + cdn.attr("href").replace("/raw/","/") );