JS file sometimes not loading
-
15-04-2021 - |
Question
I use the Mageplaza Owl Carousel. I haven't changed anything, but it doesn't always load, and I get a console error saying owlCarousel is not a function. Other times it loads as expected.
I've cleared all the caches and deployed all of the content multiple times, but it's still inconsistent. How can I get it to work normally?
This is the code
<script>
require(['jquery', 'mageplaza/core/owl.carousel'], function ($) {
$('#bannerslider-list-items-<?= /* @noEscape */ $sliderId ?>').owlCarousel(<?= /* @noEscape */ $sliderOptions ?>);
if(/Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
var widthMb = parseFloat($('.page-wrapper').width()) - 30;
$('.mp-banner-sidebar').attr('style','max-width: '+widthMb+'px');
}
});
</script>
And in the Mageplaza core module in the requirejs-config there's this entry
'mageplaza/core/owl.carousel': 'Mageplaza_Core/js/owl.carousel.min',
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange