I’m using Smartwave Porto theme for my Magento 2 website. When I load my website for the first time it’s loading properly, but every time I refresh the browser page it will show an error like this in browser console and my page does not load properly:
1 2 3 4 |
Uncaught TypeError: $(...).swMegamenu is not a function Uncaught TypeError: $(...).stellar is not a function Uncaught TypeError: $(...).owlCarousel is not a function Uncaught TypeError: $.widget is not a function |
I just do below changes :
Create a requirejs-config.js in the root of the child theme (you can also do this on root theme if you have not created a child theme) as per Porto child like this:
app/design/frontend/Smartwave/porto_child and add the following code in it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
var config = { shim: { jquery: { exports: '$' }, 'Smartwave_Megamenu/js/sw_megamenu': { deps: ['jquery'] }, 'owl.carousel/owl.carousel.min': { deps: ['jquery'] }, 'js/jquery.stellar.min': { deps: ['jquery'] }, 'js/jquery.parallax.min': { deps: ['jquery'] } } }; |
And also change child theme layout file at:
app/design/frontend/Smartwave/porto_child/Magento_Theme/layout/default_head_blocks.xml
From:
1 2 3 |
<script src="jquery.js" /> <script src="bootstrap/js/bootstrap.min.js" /> <script src="fancybox/js/jquery.fancybox.js" /> |
To:
1 2 3 |
<remove src="jquery.js" /> <remove src="bootstrap/js/bootstrap.min.js" /> <remove src="fancybox/js/jquery.fancybox.js" /> |
I don’t need the fancybox, So I have turned it off, but if you require it, I guess it should be included in the requirejs as well. If you face the same issue, follow the above steps to solve it.
[crayon-63e08eee371ce887815792/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.