I'm trying to append Google AdSense script to the head tag after page gets fully loaded. In brief here's the code that triggers the error
var tag = document.createElement("script");
tag.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
tag.data-ad-client="ca-pub-xxxxxxx"; //error gets triggered here
tag.defer="defer";
document.getElementsByTagName("head")[0].appendChild(tag);
In the console I get
Uncaught SyntaxError: Invalid left-hand side in assignment
and refers to this line
tag.data-ad-client="ca-pub-xxxxxxx";
How to fix this and if I could make it work this way, will ads appear normally?