How can I remove an outdated API from my website's code?

I tested my website in Pagespeed Insight.
The system detected that my website is using an outdated API. And the below source is:

https://alcoholpleasehk.com/cdn/shopifycloud/shopify/assets/shop_events_listener-65cd0ba3fcd81a1df33f2510ec5bcf8c0e0958653b50e3965ec972dd638ee13f.js

I found the similar codes in the source code in my main page

"
var eventsListenerScript = document.createElement(‘script’);
eventsListenerScript.async = true;
eventsListenerScript.src=“//alcoholpleasehk.com/cdn/shopifycloud/shopify/assets/shop_events_listener-65cd0ba3fcd81a1df33f2510ec5bcf8c0e0958653b50e3965ec972dd638ee13f.js”;
document.getElementsByTagName(‘head’)[0].appendChild(eventsListenerScript);
"

However, i’m not sure how to delete in my codings.
I would be grateful if anyone can share their similar experience, or guide me a bit on how to fix it.

many thanks.