• I wonder if it’s possible to ditch jQuery of frontend, at least for basic stuff, like tracking, because it doesn’t really make sense to load jQuery only for that.

    E.g. for click tracking (jquery.adrotate.clicktracker.js) you can use this:

    document.addEventListener('click', (e) => {
        const trackable = e.target.matches('a.gofollow') || e.target.closest('a.gofollow');
    
        if (!trackable) {
            return;
        }
    
        fetch(click_object.ajax_url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            body: new URLSearchParams([
                ['action', 'adrotate_click'],
                ['track', trackable.getAttribute("data-track")]
            ])
        });
    });
    

    As an alternative, maybe you let users to select which JS variant is loaded?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Arnan de Gans

    (@adegans)

    AdRotate (Pro) only uses jQuery because practically every theme loaded it a few years ago. I’m not sure if that’s still the case now, so your idea makes sense.

    I’m not really a Javascript guy, but I’ll look into replacing the current script.

    Thanks for the example code ??

    Plugin Author Arnan de Gans

    (@adegans)

    Your code indeed seems to work just fine ??
    I’ll include it in the next version.

    Reducing the reliance on things like jQuery is always good.
    Would you be interesting in converting the rotator for dynamic groups to work without jQuery as well? I’m sure it would be possible for someone more experiences in JS than me.
    Let me know if you’re interested – https://ajdg.solutions/contact/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ditch jQuery on frontend?’ is closed to new replies.