Last active
August 29, 2015 13:58
-
-
Save asross/10279381 to your computer and use it in GitHub Desktop.
Randomize the size and family of all fonts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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