Skip to content
Asynchronously load gists
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
bower.json
gist.js
gist.min.js
package.json

README.md

async-gist

Gist embeds like this one:

<script src="https://gist.github.com/matthewspencer/005044062dd93fbe59ce.js"></script>

Use document.write() which is totally uncool if you are doing stuff like history.pushState().

This plugin provides an alternative way to embed gists.

Usage

In your JavaScript you’ll want:

$('[data-gist]').gist()

Which maps to the corresponding markup:

<div data-gist="005044062dd93fbe59ce"></div>

Or if you want to embed a specific file from a gist:

<div data-gist="005044062dd93fbe59ce" data-file="access_to_tools-sh"></div>

Installation

This library can be install with npm, bower, or just by downloading the zip. It is written in the UMD pattern to support AMD, CommonJS, and global usage.

npm

npm install async-gist --save

bower

bower install async-gist --save

Options

A few options can be passed, for example, here we make the timeout 2 seconds:

$('[data-gist]').gist({
  timeout: 2000
})

timeout

Default: 1000

Description: How long to wait for the jsonp.

success

Default: onAjaxSuccess

Description: It is best to leave this alone and let the internal function do the need. It’ll load the needed stylesheet and gist content.

error

Default: onAjaxError

Description: It is also best to leave this alone. It’ll display a link to the gist on failure to load.

You can’t perform that action at this time.