calling function in external js file

i think the script.js file is not loading properly. if its loading then the function should work as expected.

are you referencing the complete path of script in your script.js call? like

<script type="text/javascript" src="https://wordpress.stackexchange.com/questions/256287/some-domain.com/path/widget.js"></script>

try opening that file from page source and see if its loading the correct js file?

its always best practice to use wp_enqueue_script function for loading js files.

error code: 523