I think the loop isn't needed here since `NewUsernameUrlEncoder.js` is one file. Try using other `AssetsManager` method here in example:

```php
$src = AssetsManager::getInstance()->getOneCommonURL( '/extensions/wikia/UserRenameTool/js/NewUsernameUrlEncoder.js' );
$wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$src}\"></script>" );
```

or even better could be changing the `SpecialRenameuser` class so it extends `WikiaSpecialPageController` and then you can have such clean code as:

```php
$this->response->addAsset('/extensions/wikia/UserRenameTool/js/NewUsernameUrlEncoder.js');
```

But it means probably a lot of changes in the only method of `SpecialRenameuser`.