The $vars array is public, so you can get at it before you call attr():
if (!isset($asset->vars['username'])) {
return NULL;
} else {
return $asset->attr('username');
}
It doesn't give the asset a chance to do something clever if the attr hasn't been loaded, but I don't know how often that method does tricky stuff anyway.