diff --git a/src/Block/Head/Preload.php b/src/Block/Head/Preload.php index 2af07cc..47d0a4c 100644 --- a/src/Block/Head/Preload.php +++ b/src/Block/Head/Preload.php @@ -23,7 +23,13 @@ public function __construct( */ protected function _toHtml() { $html = ''; - foreach ($this->getAssets() as $asset) { + $assets = $this->getAssets(); + + if (empty($assets)) { + return; + } + + foreach ($assets as $asset) { $attributesHtml = sprintf('%s="%s"', $asset['attributes']['name'], $asset['attributes']['value']); $assetUrl = $this->_assetRepo->getUrl($asset['path']); $html .= sprintf($this->_template, $assetUrl, $attributesHtml);