What is the best place to calculate differences between two versions of a text (and add corresponding "removed" and "added" css classes)?
Should this be done at the server or is it better to have client-side JS handle this?
What is the best place to calculate differences between two versions of a text (and add corresponding "removed" and "added" css classes)?
Should this be done at the server or is it better to have client-side JS handle this?
Unless you do something crazy, it shouldn't be possible to determine the revisions with just JS if you're looking at simple DOM content.
You'll want to use a combination of server-side code and JS to handle the revision checking to create a system like this, but classes like removed
and added
should probably be created server-side.
I think this may be a question of scaling. If your server can handle the load, make the comparison server side. This relieves your users (hardware) of the burden of doing the calculation, and should result in a better (read: faster) experience. However, if you've got too many of these going on at once to handle them all in a timely manner, or else you're crashing and/or running out of memory in your server side environment, by all means push it to the users. If you have reason to expect this in the future, then that's a pretty compelling reason to implement it now - your service will scale a lot better if you're farming out your processing to your users. Now that I am done writing, I am leaning to making this a client-side calculation - you distribute the load out instead of consolidating it in.