Skip to content

Commit

Permalink
webloader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed May 12, 2019
1 parent d839970 commit ff0af67
Show file tree
Hide file tree
Showing 6 changed files with 14,388 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/Utils/WebLoader/WebLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public function setDestination($dir, $url)
*/
public function render()
{
Timer::start('WebLoader-render');

if ($this->cache) {
if (!isset($this->destinationDir))
throw new \InvalidArgumentException('Please set destination dir');
Expand All @@ -146,6 +148,7 @@ public function render()

$html = '';
if ($this->cache && $this->itemsType == static::TYPE_CSS) {
Timer::start('WebLoader-render-css');
$itemsToMinimize = [];
foreach ($this->items as $item) {
// && !$item->isMinified()
Expand All @@ -154,8 +157,12 @@ public function render()
} else
$html .= $item->render();
}
Timer::start('WebLoader-render-css-minifying');
$html .= $this->_getMinimizedCss($itemsToMinimize)->render();
Timer::end('WebLoader-render-css-minifying');
Timer::end('WebLoader-render-css');
} elseif ($this->cache && $this->itemsType == static::TYPE_JS) {
Timer::start('WebLoader-render-js');
$itemsToMinimize = [];
foreach ($this->items as $item) {
// && !$item->isMinified()
Expand All @@ -164,14 +171,19 @@ public function render()
} else
$html .= $item->render();
}
Timer::start('WebLoader-render-js-minifying');
$html .= $this->_getMinimizedJs($itemsToMinimize)->render();
Timer::end('WebLoader-render-js-minifying');
Timer::end('WebLoader-render-js');
} else {
foreach ($this->items as $item) {
$html .= $item->render();
}
}
$this->items = [];

Timer::end('WebLoader-render');

return $html;
}

Expand Down
Loading

0 comments on commit ff0af67

Please sign in to comment.