This is a design question. I hope you guys will be able to help me with this.
I am developing an autocomplete control. Its basically a service based control, where the responsibility of the service call is to fetch HTML of the suggestion list (drop-down menu) when user enters a few words.
The server side code is in C# and the client side in JQuery/Javascript.
The control has been developed to use two modes:
An ASP.NET control (which initializes a jQuery widget in the generated response).
A standalone jQuery widget that uses a server side HTML generation engine.
I have kept the HTML generation engine of the suggestion menu (drop-down menu) on server. Control users can choose to cache their datasource on server. If caching is not enabled, the datasource is sent to server in each service request for HTML generation.
My question is - Should I write an HTML generation engine on client side (JQuery/Javascript) also ?
So far, I have found following pros and cons of "writing a separate client side HTML engine":
Pros:
Faster HTML generation for small to average size of suggestion list as request to server is avoided.
No server side dependency, the jQuery widget mode will be completely standalone as no server side code is required.
Cons:
Code duplicacy : Same generation engine in both C# and jQuery/javascript.
Increased maintenance : As new features/functionalities are added, changes will have to be done on both sides.