- Feb 8, 2004
- 12,604
- 15
- 81
Hey guys, so im refactoring my websites code. Right now it has the various string commands that make up the API stored in a class called ServerAPI.java on the server and a javascript file called ServerAPI.js for the client. So basically its two files with the exact same string values...
I was thinking about having the client side ServerAPI.js deriving its values directly from ServerAPI.java by using an ajax query to get them in JSON form or something like that. That way I dont have to maintain two separate files. What do you guys think? Is this a smarter plan?
Also what do you think about keeping the API stored in localstorage so it can be used on various html pages without having to refetch it from the server each time? Any pitfalls to this?
I was thinking about having the client side ServerAPI.js deriving its values directly from ServerAPI.java by using an ajax query to get them in JSON form or something like that. That way I dont have to maintain two separate files. What do you guys think? Is this a smarter plan?
Also what do you think about keeping the API stored in localstorage so it can be used on various html pages without having to refetch it from the server each time? Any pitfalls to this?