Ditch jQuery on frontend?
-
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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Ditch jQuery on frontend?’ is closed to new replies.