Announcing Nuxt.js plugin @marcdiethelm/nuxtjs-countly

A Nuxt.js plugin providing Countly's web SDK.

The plugin lazy loads the Countly tracker by adding a script element as last child in html body with async=true . It then checks for script load every 500ms for 30s, until the script is loaded or it times out. After successful script load window.Countly is injected into Vue components and Nuxt context as $countly .

Based on nuxtjs-countly by gweill, a published npm module without public source code. If you are the original author please contact me.

Stars are welcome. :wink:

Hello,
that looks cool.
But you don't have to check, you can subscribe to when SDK is loaded.
SDK has a built in hooks for extending it with plugins.

So to know when SDK is loaded, you can do something like this:

window.Countly = window.Countly || {};
window.Countly.onload = window.Countly.onload || [];
window.Countly.onload.push(function(){
    //SDK is loaded now
});

Hey thanks, good to know about the Countly.onload.push method. I don't think I ever saw that before. It's been a few months since I originally implemented this plugin. I think there was I reason why I had to do it this way, but I'm not sure now. I coded so much other stuff in the mean time that I simply forgot.

Next time there's a reason to update the plugin I'll try to get rid of the custom onload check and register callbacks using the method above.