Make social javascript functions more modular