This script works well when including it into an external file, but it fails when embedding it in the same file. This fixes it by always escaping it, which will work in embedded and external documents.
The reason why it fails is because when you embed this script into the same page with "", browsers will treat that element as a closing script tag causing the rest of the code to be treated as text.
It is good practice to always escape "" tags when using them in JavaScript.
This script works well when including it into an external file, but it fails when embedding it in the same file. This fixes it by always escaping it, which will work in embedded and external documents.
The reason why it fails is because when you embed this script into the same page with "", browsers will treat that element as a closing script tag causing the rest of the code to be treated as text.
It is good practice to always escape "" tags when using them in JavaScript.