flagrow / ads

Allows you to configure ads in several locations
https://discuss.flarum.org/d/4785-flagrow-ads-bombarding-your-users-with-ads-everywhere-if-you-want
MIT License
18 stars 9 forks source link

AdSense not loading in Firefox (No slot size for availableWidth=0) #17

Closed matteocontrini closed 6 years ago

matteocontrini commented 6 years ago

When using Flagrow Ads with AdSense banners, it seems there are problems when viewing the forum with Mozilla Firefox (tested with v63).

Particularly, this error is shown in the console every time an AdSense banner is attempted to be rendered:

TagError: adsbygoogle.push() error: No slot size for availableWidth=0

My configuration is the following. In Admin => Appearance => Custom header I put the AdSense script include:

immagine

I know it's not the best idea, but the easiest.

In Admin => Ads, I have the AdSense code for the banners:

immagine

The issue can be seen live on this forum: https://forum.fibra.click/

Or, as reported here, also on https://www.seekadventure.net/

If testing with Firefox in incognito mode, be sure to disable "Content/tracking blocking", because it blocks ads as well.

After a quick search, it appears that the issue is related to the fact that the (adsbygoogle = window.adsbygoogle || []).push({}); line is called when the rest of the code has still to be rendered on screen.

(Note: for anyone wondering, what that line is doing is creating a local variabile called adsbygoogle and assigning it the value of the global window.adsbygoogle, or an empty array if it doesn't exist. Then an empty object is pushed on that array. This works because if the AdSense script is already loaded, the push function is actually some custom code that loads the next ad slot. If AdSense is still not loaded, the adsbygoogle array will be used to know how many slots to load, as soon as AdSense is ready)

Thank you.

matteocontrini commented 6 years ago

So it wasn't actually an issue with the extension. I found out that for some reason the uBlock Origin extension I have installed was misconfigured. I had it configured in "opt in" mode, so that ads are always allowed by default, but that wasn't really working... Without the extension at all, everything's fine.

Sorry for bothering :)