Skip to content

Instantly share code, notes, and snippets.

@zinigor
Created October 26, 2015 14:45
Show Gist options
  • Save zinigor/2e6a802d7fa41ac96546 to your computer and use it in GitHub Desktop.
Save zinigor/2e6a802d7fa41ac96546 to your computer and use it in GitHub Desktop.
Test
;(function($, undefined) {
gistStylesheetLoaded = false;
var gistEmbed = function( data ) {
$('.gist-oembed').each(function(i, el) {
var url = 'https://gist.github.com/' + $(el).data('gist');
$.ajax({
url: url,
dataType: 'jsonp'
}).done(function( response ) {
$(el).replaceWith( response.div );
if ( ! gistStylesheetLoaded ) {
$('head').append(
"<link rel='stylesheet' href='" + response.stylesheet + "' type='text/css' />"
);
gistStylesheetLoaded = true;
}
});
});
};
$(document).ready(gistEmbed);
$('body').on('post-load', gistEmbed);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment