Skip to content

Commit efdd4dd

Browse files
committed
Delay creating pretty codeblocks
Only create the codeblocks when opening for the first time, to make the page load faster. Fixes php-debugbar#112
1 parent a7cce7e commit efdd4dd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DebugBar/Resources/widgets.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ if (typeof(PhpDebugBar) == 'undefined') {
200200
if (v && v.length > 100) {
201201
v = v.substr(0, 100) + "...";
202202
}
203-
var prettyVal = createCodeBlock(value);
203+
var prettyVal = null;
204204
dd.text(v).click(function() {
205205
if (dd.hasClass(csscls('pretty'))) {
206206
dd.text(v).removeClass(csscls('pretty'));
207207
} else {
208+
prettyVal = prettyVal || createCodeBlock(value);
208209
dd.addClass(csscls('pretty')).empty().append(prettyVal);
209210
}
210211
});
@@ -268,12 +269,13 @@ if (typeof(PhpDebugBar) == 'undefined') {
268269
if (!value.is_string || value.message.length > 100) {
269270
var prettyVal = value.message;
270271
if (!value.is_string) {
271-
prettyVal = createCodeBlock(value.message, 'php');
272+
prettyVal = null;
272273
}
273274
li.css('cursor', 'pointer').click(function() {
274275
if (val.hasClass(csscls('pretty'))) {
275276
val.text(m).removeClass(csscls('pretty'));
276277
} else {
278+
prettyVal = prettyVal || createCodeBlock(value.message, 'php');
277279
val.addClass(csscls('pretty')).empty().append(prettyVal);
278280
}
279281
});

0 commit comments

Comments
 (0)