Avoiding anonymous JavaScript functions