I'm deciding on how to generate the code to allow users generate an embeddable widget (much like the StackOverflow badge) into external websites.
The content of the embedded widget will periodically change, but it doesn't need to be communicating in real-time with my server after a visitor has loaded the page where it's embedded.
This opens up several possibilities for getting this to work:
On the server, pre-generate the static html content I want rendered in their page (and have a scheduled job which regenerates the static file). My users can then embed it in their page using an iframe reference to the static resource.
Same as above, but instead of the iframe I create a js file which they reference (much like an Google Analytics code) and then the js file served inserts the data in into their DOM. My web server would need to dynamically generate the js file on each request for the file resource.
Give them a js file which creates the element on their page like the above, except the js file payload doesn't include all the data and instead basically generates the DOM element as a template, then calls web services to populate the data (like their name and score) using JSONP requests to my server.
I like 2 for the explicit server-side control, but it will take more time. 3 is good because the services I expose to retrieve this data can be reused for other purposes later. I don't generally like iframes, but they work and are very quick to implement.
Any suggestions of which way to proceed or ideas that I've missed?