I have a page when user can add 0 to N TinyMCE editors that need to have some div soup around it.
I have the html code in a gsp _template because it is more then a few lines and I didn’t want to stuff it in javascript. Basicaly everytime user clicks “add editor”, an ajax call is made to the server with new id as the only parameter, controller renders the template with elements properly named using the new id, and it is appended by javascript to the page.
I think its a pretty elegant solution, but what bothers me are the ajax calls that are fired for every new editor that is to be added to the page which has always the same code apart from different element id’s.
Will this have any performance impact? Is the template cached after first call?
Thanks
The GSP should be compiled (pre-compiled on grails war) and then there is some caching to help speed up GSP rendering. The performance issues are no different than considering any amount of traffic. The server doesn’t care (or know) that the request is Ajax. It is just responding to a request. IF you remove ajax from your equation and just look at it that way, would you still be asking the performance question?
That said, if all you need is an ID attached to the elements in the template, I might look into something like a javascript template solution (jquery.template() for example). That would negate the call to the server entirely.