Prevent blank textnodes, accept jquery element and insert script within last html node when possible.