I recommend using the suggested code snippet, this check for the current URL doesn’t affect any performance (checking the current URL doesn’t query the database, it’s a simple PHP runtime check and WordPress does thousands of similar conditional checks on every page refresh). Performance is mostly affected by complex database queries or client-side content (JS/CSS, image optimization).
If you don’t want to add inline JS, you can add the “script” tag in the same snippet with the script URL, or use the same approach with checking the current URL but for the wp_enqueue_scripts
hook.
The functionality you described (conditional fields visible or hidden depending on the selection) is not in the form yet so custom JS logic would be required here in any case.
Hope this helps