The client can cache the .js
file locally (prevent it from downloading) but the operation the said file performs is performed on every load.
As for Google Maps, it needs to perform its operations to display the map. Other then letting the client cache the .js
file (thus saving the download), there is not much you can do.
The best you can do is limit the amount of processing the client needs to do, or if the result of your processing is scalar (Strings, numbers, array of), you can store it in a cookie for later use. DOM manipulation is done on every load.
Do all your heavy processing on the server when possible.