Fix a Javascript error when no callback function is provided