Skip to content

Instantly share code, notes, and snippets.

@asross
Last active August 29, 2015 13:58
Show Gist options
  • Save asross/10279381 to your computer and use it in GitHub Desktop.
Save asross/10279381 to your computer and use it in GitHub Desktop.
Randomize the size and family of all fonts.
function randomizeFonts() {
if (window.jQuery) {
elements = jQuery('*');
families = jQuery.unique(elements.map(function() { return jQuery(this).css('font-family') }));
families.push("'comic sans ms', sans-serif");
elements.each(function() {
jQuery(this).css('font-size', 32*Math.random() + 'px');
jQuery(this).css('font-family', families[Math.floor(Math.random()*families.length)]);
});
} else {
var jq = document.createElement('script'); jq.type = 'text/javascript';
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(jq);
setTimeout(randomizeFonts, 0.1);
}
}
randomizeFonts();
setInterval(randomizeFonts, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment