wemake-services / vue-analytics-facebook-pixel

A small wrapper around Facebook Pixel API
MIT License
24 stars 19 forks source link

Decent, modern Facebook Pixel API loading #7

Open szepeviktor opened 4 years ago

szepeviktor commented 4 years ago

Has anyone rewritten this in a Vue-ish way?

function(f, b, e, v, n, t, s) {
  if (f.fbq) return;
  n = f.fbq = function() {
    n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
  };
  if (!f._fbq) f._fbq = n;
  n.push = n;
  n.loaded = !0;
  n.version = '2.0';
  n.queue = [];
  t = b.createElement(e);
  t.async = !0;
  t.src = v;
  s = b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t, s)
}(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');

Maybe with vue-plugin-load-script and meaningful variable names?

szepeviktor commented 4 years ago

Please see my try on this https://gist.github.com/szepeviktor/909c1bcfc0a6eb2197f1d4e0c6a60a1c