I am having a bit of strange behaviour with Magento 2 require.
What I trying to do is to use glide.js to load carousel image. I create custom.js and here is my code.
require(['jquery', 'lib/glide'], function($){ $(function(){ var carousel = $('#Glide').glide({ //instantiating glide type: 'carousel', startAt: 1, touchDistance: 2, autoplay: true, animationDuration: 800 }); }); }); This kind of works 90% of the time but it's temperamental. sometimes it gives error: Uncaught ReferenceError: jQuery is not defined and Uncaught TypeError: jQuery(...).glide is not a function.
The library needs jquery so it seens that sometimes something goes wrong and it can't find jquery lib.
Does anyone came across this before or I am doing something wrong.
Your help is appreciated. Thank's