The goalkeeper is forced to come to the edge of the penalty area on the left side to clear a ball away and in doing so has to slide outside the area to clear the ball into the stands.

An attacking player quickly grabs a new ball from a ballkid and throws it in while the goalkeeper is caught way out of position.

As a referee, I would make the attacking player retake the throw-in, giving the keeper time to get back to his penalty area.

(My rule of common sense) These extra balls certainly speed up the game but are increasingly used to gain advantage.

Especially with home teams.

Is there a memorandum regarding this or is it a referee judgement call?

And what should the ruling be?

USSF answer (August 23, 2011):
The Law does not ask us to compensate for the mistakes of players. Indeed, the Law clearly instructs us NOT to compensate for such errors. However, the referee might be more sympathetic in some cases, based on the age and experience level of the teams. This Q&A from the IFAB’s “Questions and Answers” 2006 (Law 3) provides the information you need:

“20. During a match, the goalkeeper sprints from the goal to stop an opponent. He kicks the ball out of the field of play and a throw-in is awarded to the opposing team. The momentum of the goalkeeper takes him off the field of play and before he can return, the throw-in is taken and a goal is scored. What action, if any, should the referee take?

“A goal is awarded since no offence has been committed.”

As for procedure in replacing a ball that has left the field , the referee should ensure throughout the game that the ball boys and girls provide equal service for both teams.

In addition, there is always the possibility that the referee COULD question the legality of the new ball (“Did I really check this one before the game or is this a different one?”) while, of course, requiring a ceremonial restart..