If I hide some scripts from Google bot, will it be considered as cloaking?

I have a website built with Gatsby.js. After building it, I receive a lot of static HTML files, with React app bound to them. All content is in HTML already, JS is needed for some fancy transitions, forms and analytics. What I want to do, is loading only some (or maybe even none) of the scripts when Google bot requests the page.

As I read here, you are fine as long as you’re producing similar content for Google bot and for real users (and HTML content is exactly the same for both in my case).

But it is also said (sorry, cannot find the link where I saw this) that your tactic may be considered shady if you have any sort of conditions like if (userAgent === "googlebot") then ... else ... in your code (and this is actually my intent).

So my question is, will Google ban me for this or not?