idan/gistio — pull request #27 by doda (2012-07-20 04:28:47+00:00)
Title: syntax highlighting & client-side querying

this pushes all the work of requesting the Gist's contents, rendering them, applying the correct syntax highlighting and sanitizing the HTML to the client.

general thoughts reg. this approach

Advantages:

- generally faster load times as there's no round-trip through the flask app
- greatly simplifies hosting, no more worrying about github API limits
- eliminates almost all dependencies on the server, basically all that is required is serving up the static files
- no maintaining redis & worrying about abuse
- freedom to implement whatever features we want, having gist contents + comments would ~~castrate~~ limit the web app to 2500 requests / hour (5000 / 2), if the client does the work of querying GitHub we can pull in however much information we want

Disadvantages:

- on pages that would be cached, resolving the github DNS, and then client-side running the logic to turn it sanitized HTML might be a couple hundred ms slower
- initial load is a couple dozen kB higher since sanitization happens on the client

In general I think it's a great improvement since it greatly simplifies everything that happens on the server and even though I prefer doing Python over JS, it's nicer to have everything in one place instead of having it split between python on the server and JS on the client and constantly making sure the 2 match up.