Skip to content

Instantly share code, notes, and snippets.

Last active February 20, 2016 16:15
What would you like to do?
A simple JavaScript function that doubles every character on a web page – useful when testing layouts for i18n issues
// Paste this function to your browser’s JavaScript console,
// and then run it, passing in a CSS selector, eg:
// > pseudolocalize('body')
var pseudolocalize = function pseudolocalize(arg){
if(typeof arg === 'string'){
var elements = document.querySelectorAll(arg);
for(var i=0, len=elements.length; i<len; i++){
} else if(arg.nodeType === 1){
for(var i=0, len=arg.childNodes.length; i<len; i++){
} else if(arg.nodeType === 3){
arg.nodeValue = arg.nodeValue.replace(/(.)/g, '$1$1');
var pseudolocalize=function e(l){if("string"==typeof l)for(var o=document.querySelectorAll(l),d=0,n=o.length;n>d;d++)e(o[d]);else if(1===l.nodeType)for(var d=0,n=l.childNodes.length;n>d;d++)e(l.childNodes[d]);else 3===l.nodeType&&(l.nodeValue=l.nodeValue.replace(/(.)/g,"$1$1"))};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment