I'd have put the singleton link creation before the for loop.
```
if (resources.length > 0) {
  let jsonLink = ...;
  resources[0].parentNode.insertBefore(jsonLink, resources[0]);
  for(..) {...}
}
```