The error makes no sense to me, as the same code works on many other sites without any issues. Just to be sure please turn off any caching and “script optimization” so the JavaScript assets get loaded as they are provided with the plugins and not as one single minified file for all scripts on your site.
Also keep in mind that the server on which your website is hosted already uses HTTP/2 – so minifiying everything to one single file will not improve the performance anyway since with HTTP/2 browsers request included CSS and JavaScript files in one single connection and parallel. It makes no difference if there is only one file or many.
For example – open my website https://arnowelzel.de and use the web developer tools of your browser to see the “waterfall” for the HTTP requests in the network tab. Due to HTTP/2 many elements get requested at the same time and downloaded in parallel. Also see this screenshot:
https://nextcloud.0x0c.de/s/afKiQo4GrSgFL7S/preview