Add pruneTextNodes function to JavaScript