JavaScript lazy DOM builder/matcher