Can I hide links with params into custom HTML attr?

Hey everyone! Quick question — does anyone know a good way to hide links with URL parameters (basically any link containing a “?”) by moving them into a custom HTML attribute like data-href, and then handling the navigation via JavaScript? The reason is purely SEO-related — I have a lot of such links on my site, and since robots.txt directives are more like suggestions these days rather than strict rules to prevent crawlers from crawling those links, I’m looking for a better approach, which is the best one I know at the moment (yup, I have the noindex/nofollow for those links also, but crawlers are able to see them only after downloading the HTML which is still a waste of the crawl budget)

I do not know ready-to-use solutions since there can be problems with ajax requests, etc.