Fitvids and script dependency issue

Hi all, I’ve got a bit of a puzzle. I added a bit of code to my site to defer loading of scripts, including jquery.js.
I mention jQuery specifically, because all the scripts load fine until I defer that one. But I’m using ‘defer’ to ensure script order is preserved, and the error isn’t directly connected to jquery.js. It is this:

scripts.js?ver=1:2 Uncaught TypeError: $(...).fitVids is not a function
    at HTMLDocument.<anonymous> (scripts.js?ver=1:2)
    at i (jquery.js?ver=1.12.4-wp:2)
    at Object.add [as done] (jquery.js?ver=1.12.4-wp:2)
    at n.fn.init.n.fn.ready (jquery.js?ver=1.12.4-wp:2)
    at a.fn.init.n.fn.init (jquery.js?ver=1.12.4-wp:2)
    at new a.fn.init (jquery-migrate.min.js?ver=1.4.1:2)
    at n (jquery.js?ver=1.12.4-wp:2)
    at scripts.js?ver=1:2

Of course, those line numbers aren’t quite right, since the files are minified. The error actually happens here in scripts.js:

//Fit Vids
jQuery(function($) {



Looking at my page source, scripts.js loads before jquery.fitvids.js, and so the error makes sense, and flipping the order solves the problem (until the next Moesia Pro update).
I’ve no idea why it works when one leaves jquery.js non-deferred, but it is definitely broken when jquery.js IS deferred. If the script order/dependencies could be corrected in the next version, that would be great. Thanks!

1 Like

Hello there,

Thank you for reaching out to us and reporting this.

I will pass this to our development team and fix it as soon as possible in upcoming update.

At the time being, to temporarily fix it, please try doing these steps:

  1. Install and activate the TC Custom JavaScript plugin
  2. Go To Appearance > Custom JavaScript
  3. Paste the following code into the provided box
    jQuery(function($) {
  1. Update
  2. Flush any applied cache

Let me know how it goes.

aThemes Support

1 Like