Skip to content

Commit 56b0762

Browse files
committed
Load Tracy at top of head so it's not waiting on other slow scripts.
1 parent 120a08d commit 56b0762

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

TracyDebugger.module.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.26.82',
30+
'version' => '4.26.83',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -1162,8 +1162,18 @@ public function init() {
11621162
$adminerModuleId = $this->wire('modules')->getModuleID("ProcessTracyAdminer");
11631163
$adminerUrl = $this->wire('pages')->get("process=$adminerModuleId")->url;
11641164

1165+
ob_start();
1166+
\Tracy\Debugger::renderLoader();
1167+
$tracy_loader = ob_get_clean();
1168+
$event->return = preg_replace(
1169+
'/<head\b[^>]*>/i',
1170+
'$0' . "\n" . $tracy_loader . "\n",
1171+
$event->return
1172+
);
1173+
11651174
$event->return = str_replace("</body>", "<script>window.HttpRootUrl = '".$this->wire('config')->urls->httpRoot."'; window.AdminerUrl = '".$adminerUrl."'; window.AdminerRendererUrl = '".$adminerRendererUrl."'; window.TracyMaxAjaxRows = ".$this->data['maxAjaxRows']."; window.TracyPanelZIndex = " . ($this->data['panelZindex'] + 1) . ";</script></body>", $event->return);
11661175

1176+
11671177
$tracyErrors = Debugger::getBar()->getPanel('Tracy:errors');
11681178
if(!is_array($tracyErrors->data) || count($tracyErrors->data) === 0) {
11691179
if(($this->data['hideDebugBar'] && !$this->wire('input')->cookie->tracyShow) || $this->wire('input')->cookie->tracyHidden == 1) {

0 commit comments

Comments
 (0)