Search code examples
javascriptjquerynoty

$.noty is not a function


A page on my site uses Noty to display notifications. I'm loading Noty 2.4.1 (jquery-noty) and jQuery 3.5.1 from a CDN (cdnjs) and I show notifications like this:

$.noty({text, timeout, type, layout});

This configuration has been working fine ever since I first set up that code, but now, without any change from me, I get the following:

Uncaught TypeError: $.noty is not a function

Indeed, if I go to the console and type $.noty, I see an object, but if I type $.noty() I get:

TypeError: $.noty is not a function

Browsers tested:

  • Firefox 84.0.2 (32-bit)
  • Microsoft Edge 88.0.705.50

This is really strange as I haven't touched that code in a long time. Could they have implemented some breaking change to the version served via CDN? What can be done to make Noty 2.4.1 work again?

On CodeSandbox you can find a reproducible example.


Solution

  • The current version of Noty is 3, and I simply ported my existing configuration from 2 to 3 by calling it like this:

    new Noty({text, timeout, type, layout}).show();