I was looking to setup Google AdSence to monetize my multi-page site, and was wondering if would be ok if I placed the script externally so I can easily edit it and delete it on all pages if necessary.
The code I would but in the location I want the ad:
<script src=”ad-1.js”></script>
And I would copy the AdSence code (Minus the < Script > tags) into the “ad-1.js” file.
Would this be breaking any AdSence rules? Also, is there any way to avoid Ad blockers from blocking the ads?
Edit: I signed up for AdSence, and searching the docs and Google finds me no additional information. Does anyone know if this violates any rules?
So, I found an answer, and posting it here for others that may come across this question.
You can use the jQuery "Get Script" command, like this:
In the HTML file:
//Calls jQuery
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
//Calls external js file
<script src="/header.js"></script>
header.js:
$.getScript( "LINK TO CALL GOOGLE ADS" )
ANY ADDITIONAL CODE THAT GOES INSTIDE THE <SCRIPT> TAG GOES HERE