Skip to content

Commit ef4101c

Browse files
committed
only load Sfjs if it is not present
Plus, avoid loading the toolbar if it is no longer on the page
1 parent a013215 commit ef4101c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Resources/views/Profiler/base_js.html.twig

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
them as JavaScript source code. Always use '/*' comments instead
66
of '//' comments to avoid impossible-to-debug side-effects #}
77
8+
if (typeof Sfjs === 'undefined') {
89
Sfjs = (function() {
910
"use strict";
1011
@@ -424,6 +425,10 @@
424425
'sfwdt' + token,
425426
'{{ url("_wdt", { "token": "xxxxxx" })|escape('js') }}'.replace(/xxxxxx/, newToken),
426427
function(xhr, el) {
428+
/* Do nothing in the edge case where the toolbar has already been replaced with a new one */
429+
if (!document.getElementById('sfToolbarMainContent-' + newToken)) {
430+
return;
431+
}
427432
428433
/* Evaluate in global scope scripts embedded inside the toolbar */
429434
var i, scripts = [].slice.call(el.querySelectorAll('script'));
@@ -799,5 +804,5 @@
799804
Sfjs.createTabs();
800805
Sfjs.createToggles();
801806
});
802-
807+
}
803808
/*]]>*/</script>

0 commit comments

Comments
 (0)