3

I use Laravel mix to manage my js files, here is my app.js :

window.$ = window.jQuery = require('./jquery-1.11.2.min.js');

require('./jquery.easing.1.3.js');
require('./bootstrap.min.js');
require('./SmoothScroll.js');
require('./jquery.scrollTo.min.js');
require('./jquery.localScroll.min.js');
require('./jquery.viewport.mini.js');
require('./jquery.countTo.js');
require('./jquery.appear.js');
require('./jquery.sticky.js');
require('./jquery.parallax-1.1.3.js');
require('./jquery.fitvids.js');
require('./owl.carousel.min.js');
require('./isotope.pkgd.min.js');
require('./imagesloaded.pkgd.min.js');
require('./jquery.magnific-popup.min.js');
require('./gmap3.min.js');
require('./wow.min.js');
require('./masonry.pkgd.min.js');
require('./jquery.simple-text-rotator.min.js');
require('./all.js');

the all.js contains all the logic and inits , so my problem is that some jQuery plugins don't work :

Uncaught TypeError: $(...).magnificPopup is not a function at init_lightbox (index.js?id=f95f3419a2325063a526:11289)

when I load my js in the traditional way <script ... in the same order as above all works but when I require them it throws the error, please help, thank You

EDIT:

The init functions fire after the ducument is ready (in all.js) :

$(document).ready(function(){

        $(window).trigger("resize");            
        init_classic_menu();
        init_fullscreen_menu();
        init_side_panel();
        init_lightbox();
        init_parallax();
        init_shortcodes();
        init_tooltips();
        init_counters();
        init_team();
        initPageSliders();
        init_map();
        init_wow();
        init_masonry();
});

2 Answers 2

3

So the solution was to install the jQuery via npm and instead of

window.$ = window.jQuery = require('./jquery-1.11.2.min.js'); 

do

window.$ = window.jQuery = require('jquery');

that has solved the problem!

Sign up to request clarification or add additional context in comments.

Comments

0

It looks like there is a problem with Magnific-Popup

It's because Modernizr adds video CSS class to HTML element, which is the same as selector of your popup.

Do you happen to use class video anywhere on your website? Maybe Magnific-Popup is accidentally targeting your HTML element.

5 Comments

hi, thank You , unfortunately this is not the case, the functions are fired after the document ready event , I have updated the question and included the snippet
Cool, I just edited my answer. It kind of makes sense because we would see something like $ is not defined if jQuery was not initialized correctly.
nope, not a single "video" class, the issue must be form the webpack , coz if I load the scripts on the page in a traditional way using <script> tags it all works
Maybe turn off js minification?
it is in dev mode so it is not minifying

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.