`Element#scriptWith` might simplify this a tiny bit.