Skip to content

Instantly share code, notes, and snippets.

@chrisramsay
Created February 4, 2013 19:52
Show Gist options
  • Save chrisramsay/4709143 to your computer and use it in GitHub Desktop.
Save chrisramsay/4709143 to your computer and use it in GitHub Desktop.
js-prettify
(function() {
var prettifyPath = "//jp-cdn.appspot.com/js/prettify/";
var prettifyJS = prettifyPath + "prettify.js";
var prettifyCSS = prettifyPath + "prettify.css";
var jqueryJS = "//jp-cdn.appspot.com//js/jquery.js";
function jQueryExists() { return typeof jQuery !== 'undefined'; }
//get jquery
if(jQueryExists())
gotJQuery();
else {
document.write('<script src="'+jqueryJS+'"></script>');
var interval = setInterval(function() {
if (jQueryExists()) {
clearInterval(interval);
gotJQuery();
}
}, 100);
}
//got jquery
function gotJQuery() {
$("head").append('<link href="'+prettifyCSS+'" rel="stylesheet"></link>');
jQuery.ajaxSetup({ cache: false });
$.getScript(prettifyJS, gotPrettify);
}
//prettify!
function gotPrettify(){
$(document).ready(window.prettyPrint);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment