added onBefore config options for script and static responses