Changes were made to the Text Widget in WordPress 4.8. The editing experiencing was enhanced in some ways but this also caused issues with certain HTML tags and formatting.
Fortunately, a new Custom HTML Widget was added in WordPress version 4.8.1. The Custom HTML Widget allows <script>
tags, and will not remove certain formatting unlike the new version of the Text Widget: