The answer proposed on this page by snapo is to move all the javascript to one line in between the <script> and </script> tags.
<script>
</script>
That works for me in Hugo 56.3