DOM generator utility - JavaScript