Skip to content

Magento 2 How to stop JS script in certain user agents

We are using magento 2.4.7-p3
I have a js script inserted in

admin > content > Configuration > MyStoreView > Html Head > Scripts
and Style Sheets

script is from external adress and it runs in every page before head closing tag.

But we don’t want this script to run when bots like Google or Bing crawling the site.

Is that possible please and how?