The json object is the desired approach in my mind, being that you are using jQuery UI. If you don't have a way to keep a counter on the Tag list for each tag, automatically as the user tags and un-tags, then you can either generate it on the client side
This could be time consuming depending on 1) number of tags and 2) number many articles. Building should be a no-brainer: loop through each Tag and do a GetListItems on that tag and store the amount of records found. The downside
is the time this will take, which will prevent you from displaying the UI to your user (not ready yet).
There are ways you can sacrifice the wait time of one user for the good of all: once you generate the json object the first time, store it in list. Then re-use that already create json object if it is not older than (for example)
10 minutes... or better yet.... if it is not older than the date/time of the last time a page was touched (in your pages library)... you can quickly find that out by (I think) checking the Document Library "list" level attributes (GetList) or doing a GetListItems
from the Pages library (remember to do recursive) for any page whose modification date/time is greater than the last time you stored the json data.
I use this approach of "caching" across a site today (even across multiple sites under the same farm)... Yes the user that actually triggers a rebuild of data does experience a longer delay... but helps everyone else, including
that user when he comes back to the page... and... (hehehe) it is unlikely that user will complain because he will not be able to recreate on demand. I use a "hidden" table called ptAppConfig with a few columns of different types, case I need to store
different type of data (like HTML for template snippets). The Title column is used as a unique key, which ensure I don't duplicate through out my applications.
SPDesigner / Workflow - Store totals on each Tag:
Perhaps you can devise a way to update the tags each time a Page is Tagged or un-tagged by keeping the value updated in the Tag's list... As you mentioned, this is a little getto... but could work... I'm not sure how to do it via
a Workflow (I currently do this via a workflow but not for a field that is Multi-Select)... On the client (on the NewForm, EditForm pages) this could be done by intercepting the "OK" button and updating the Tag Number first then allowing the update to go through...
Overall, this approach might be troublesome because of deadlock contention: what if two or more user go after the updat at hte same time? When done client side, you would have to first retrieve the tag's row to get the current "count"
then +1 and save it back.. in that same time another update could have gotten in there..
SPDesigner - Generate the json on the server:
Maybe use SP Designer to build a webpart that builds your json object at runtime and inserts it into the page. Like that it will be available on the client side when the page is rendered. I am not sure if this is possible (now that
I think about the steps that would need to happen) via SP designer.
Hope this helps.