• Hi,

    The plugin loads the lightbox in a <script> tag like this:

    function ytc_init_MPAU(){jQuery(‘.ytc-lightbox’).magnificPopupAU({disableOn:320,type:’iframe’,mainClass:’ytc-mfp-lightbox’,removalDelay:160,preloader:false,fixedContentPos:false});}jQuery(window).on(‘load’,function(){ytc_init_MPAU();});jQuery(document).ajaxComplete(function(){ytc_init_MPAU();});

    But if jQuery is not loaded yet (defer/async), it’ll throw an error. I fixed it by wrapping the $js variable like this:
    window.addEventListener(‘DOMContentLoaded’, function() { $js });

    We can also check if jQuery is loaded with a
    if (window.jQuery)
    if running it after pageload is not acceptable for some.

  • The topic ‘Loading jQuery async/defer throws error in page’ is closed to new replies.