It appears that gist.js is always loaded, therefore this extra complexity is not needed. It was causing random timing issues where the gist wouldn't load some of the time so I removed it.