jquery.dfp.js
jquery.dfp.js copied to clipboard
Insertion of gpt.js fails when the document doesn't have existing scripts
Not having scripts in the head or body might be weird but is quite prevalent as can be gauged by websites like http://www.csszengarden.com/215/. It will be nice to make jquery.dfp defensive as opposed to failing badly in such a scenario.
TypeError: Cannot read property 'parentNode' of undefined
at dfpLoader (chrome extension://bekccbechiigcepdoebmbganlaehelkj/bower_components/jquery.dfp/jquery.dfp.js:545:17)
var useSSL = 'https:' === document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
How do you insert the script without having any script-Blocks on the page?
Also, the lib requires jQuery. How are you using it?
On 19. feb. 2016, at 18.16, Venkat Karun [email protected] wrote:
Not having scripts in the head or body might be weird but is quite prevalent as can be gauged by websites like http://www.csszengarden.com/215/. It will be nice to make jquery.dfp defensive as opposed to failing badly in such a scenario.
TypeError: Cannot read property 'parentNode' of undefined at dfpLoader (chrome extension://bekccbechiigcepdoebmbganlaehelkj/bower_components/jquery.dfp/jquery.dfp.js:545:17)
var useSSL = 'https:' === document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); — Reply to this email directly or view it on GitHub.
The parent script that requires $.dfp is inserted as a chrome extension content script. jquery itself is required from the parent script.
Hey @venkatkarun send me a pull request with something that works for your page and I will make sure it works elsewhere and merge it.