– fuzzybabybunny Mar 15 '16 at 09:27

  • Yeah, `var c = document.getElementById("cp_widget_a718e3a7-4a35-4f13-b14e-299cc73c6ecb");` doesn't work. I think they're using `var c = document.getElementsByTagName("script")[0];` simply as an anchor so that `c.parentNode` is the `` tag. In the working example in my OP, `c = document.getElementsByTagName("script")[0]` is just some random Meteor ` – fuzzybabybunny Mar 15 '16 at 09:35
  • Updated my answer @fuzzybabybunny – Tarang Mar 15 '16 at 09:37
  • `_cpmp = _cpmp || [];` returns a `_cpmp is not defined` error. – fuzzybabybunny Mar 15 '16 at 09:43
  • Try `window._cpmp = window._cpmp || [];` – Tarang Mar 15 '16 at 09:45
  • Ok, that works. I'm not sure why though. The `libasync.js` code that Cincopa provides has `var _cpmp = _cpmp || [];` as the first instance where `_cpmp` appears. So basically it's setting `_cpmp` as the current value of the global variable `_cpmp`, OR, if it's undefined, as an empty array? – fuzzybabybunny Mar 15 '16 at 09:50
  • 1
    The Cinpopa library is lazy loaded.The library is loaded after and looks for this variable in case there is a previous definition (such as a run of onRendered twice). When you use `var _cpmp` it runs this statement before it looks at the statement after the equals sign so thats '_cpmp'. Just removing `var` is not that simple and I didn't realize it, using `window` provides the same effect as global scoping, without the use of `var`. The original edit was a mistake on my part for not taking this into account. – Tarang Mar 15 '16 at 09:54
  • Why would I need to make the `_cpmp` outside the ` – fuzzybabybunny Mar 15 '16 at 09:55
  • 1
    Yes using `var` in a script tag places it in the global context, using `var` in a `function(){..}` of any sort scopes it so that it can't be accessed outside of the `function(){..}` block, such as the onRendered one. This was the original issue that stopped it working. If you declared the variables in ` – Tarang Mar 15 '16 at 09:58