Since few days i try to fix issue with my mCustomScrollbar plugin and i got stuck.

First of all i i've got library with mCustomScrollbar.js and mousewheel.js in


and my script in

web/js .

I added mCustomScrollbar.js and mousewhell.js to requirejs-config with path and shims.

My script looks like:

function ($, mCustomScrollbar) {
    'use strict';
    return function (config, element) {
            theme: 'dark'

The problem is - when i open page (where my script is applying) sometimes console shows

Uncaught TypeError: $(...).mCustomScrollbar is not a function

and script doesn't work. Sometimes it works perfect. I don't know why it happens differently. When i open my page first time all looks good when i refresh - it depends, sometimes still works good (no errors, script applied) but sometimes doesn't work (with error above).

Can anyone tell me what wrong i do or why it happens differently?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.