How to change the link address from internal to external

Just replace plugins_url('script.js', __FILE__) with 'https://site2.com/script.js'.