Skip to content

Commit

Permalink
Replace require usage with vanilla javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
robaimes authored and guvra committed Sep 4, 2023
1 parent 81a301d commit ffaf528
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions view/base/templates/loader.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@ $viewModel = $block->getData('viewModel');

<?php if ($viewModel->isToolbarEnabled()): ?>
<script>
require(
['jquery'],
function ($) {
$('document').ready(function () {
$.ajax({
url: '<?= $escaper->escapeUrl($block->getUrl('smile_debug_toolbar')) ?>',
success: function (html) {
$('body').append(html);
},
error: function (xhr) {
console.log('Failed to load the debug toolbar: ' + xhr.responseText);
}
});
});
}
);
document.addEventListener('DOMContentLoaded', () => {
fetch('<?= $escaper->escapeUrl($block->getUrl('smile_debug_toolbar')) ?>', {
method: 'GET',
}).then((response) => {
return response.text();
}).then((html) => {
const fragment = document.createRange().createContextualFragment(html);
document.body.append( fragment);
}).catch((error) => {
console.log(`Failed to load the debug toolbar: ${error}`);
});
});
</script>
<?php endif ?>

0 comments on commit ffaf528

Please sign in to comment.