I’m no expert, but always curious what can be done client-side on stuff like this. AFAIK, for js, file access requires user interaction so you’d likely need to render a file input and file read is async so not likely to be evaluated using expression syntax.
For client-side, this would be a good fit for @josecgomez 's epiCalculator chrome extension method. Kinetic Web UX Enhancement Extension - Bringing Back the Context Calculator, Copy / Paste and More
All that’s to say you’re probably on the right track with server-side functions.