What is the purpose of charset attribute of script element in HTML?

character-encoding, html, javascript

Solution

If your javascript files are encoded with a different encoding than the page is using, you can use the `charset` attribute to tell the browser how to interpret it.

For example, if the page is using `Latin1`, but the JS file was created with `UTF-8`.

Problem

In HTML, script element has optional charset attribute. What is the purpose of it? When is it useful?

Original source