- This topic has 12 replies, 3 voices, and was last updated 1 year, 6 months ago by
David.
-
AuthorPosts
-
December 23, 2020 at 12:05 pm #1592455
Edivaldo
How do I define the space before the ads are loaded, and thereby improve the Cumulative Layout Shift?
What would be the best approach to do this, and if possible, give me an example.
Thnaks!
December 23, 2020 at 1:02 pm #1592505Leo
StaffCustomer SupportHi there,
Not sure if I fully understand.
Any chance you can link me to the page in question?
How is the ad loaded?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 23, 2020 at 1:13 pm #1592518Edivaldo
https://www.edivaldobrito.com.br/
ads loaded = adsense ad
December 23, 2020 at 1:18 pm #1592526Edivaldo
the ad is loaded via script added to the page’s html using the Head and Footer plugin!
December 23, 2020 at 1:41 pm #1592535Leo
StaffCustomer SupportThere is no way to add some padding before the ads are loaded and remove it afterwards unfortunately.
It will not solve the CLS issue either as far as I understand.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 23, 2020 at 1:47 pm #1592540Edivaldo
It resolves, or at least improves the CLS.
It turns out that when the ads are loaded, they force the redesign of the layout as they do not yet have a space reserved for them.
I just want to reserve these spaces in advance to avoid this.
December 23, 2020 at 4:05 pm #1592628Leo
StaffCustomer SupportLooks like you’ve removed the ad at the top of the page so the issue is resolved now?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 23, 2020 at 5:01 pm #1592652Edivaldo
No. I am still waiting for an answer to the question.
December 23, 2020 at 6:02 pm #1592673Leo
StaffCustomer SupportThere isn’t a way to add padding to reserve a space for the ad the remove the padding after the ad is loaded unfortunately.
I’d think the best way to avoid adding ads in the header area to completely avoid this issue.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 24, 2020 at 3:54 am #1593008Edivaldo
I’m going to rephrase the question because the fact that it’s an ad is getting in the way of your answer.
Imagine that I have an image that will be loaded after the page. Only I need to reserve a space for it before loading it. How do I do?
December 24, 2020 at 4:30 am #1593039David
StaffCustomer SupportHi there,
that will vary from advert to advert. If the Ads are autoloaded then there is no simple way to identify where the ad will be placed or what an CSS Class could be used.
For ads that you place in a specific position then you can wrap the ad script in a
<div>
with a CSS Class like so:<div class="ad-min-400"> <!-- ad script here --> </div>
then use some CSS to give it a min height:
.ad-min-400 { min-height: 400px; } /* Change height on smaller screens if required */ @media(max-width: 768px) { .ad-min-400 { min-height: 400px; } }
The problem with this method, is if the adverts are responsive then this height may vary to an unknown size. This really is an issue that should be resolved at the source. Or maybe use the Ad Inserter plugin to place your ads as i believe this will ensure the correct sizes are available when the DOM content is loaded.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 24, 2020 at 5:00 am #1593065Edivaldo
This will work as the ads have defined maximum sizes and locations.
December 24, 2020 at 5:04 am #1593070David
StaffCustomer SupportGlad to hear that
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.