Adsense Ads, Any JavaScript, YouTube Player Loading Twice!
Topics related to Realistic theme goes here.

TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Adsense Ads, Any JavaScript, YouTube Player Loading Twice!

linkPost by TahMiD » Fri Apr 13, 2018 8:25 pm

My site (https://techubs[.]net) is loading ads, Any JavaScript, YouTube Player twice on every page load. When the page loads, the ads, YouTube Player load right away, then disappear for a second and new one are loaded. Can you tell me why this is happening? No problem with another theme.

All was disabled all plugins, but still the same problem!

Thanks!
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: Adsense Ads, Any JavaScript, YouTube Player Loading Twice!

linkPost by TahMiD » Fri Apr 13, 2018 8:39 pm

I have noticed that this same problem is also on your site!
Check This Link; http://realistic[.]themient.com/2015/04/03/youtube-embeds/

This Page is loading YouTube Player twice. When the page loads, the YouTube Player load right away, then disappear for a second and new one are loaded.

Please fix this bug as soon as possible. It's so annoying and it has adverse effects on AdSense.
User avatar
Asmi Khalil

Site Admin Rank
Posts: 707
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: Adsense Ads, Any JavaScript, YouTube Player Loading Twice!

linkPost by admin » Sat Apr 14, 2018 11:30 pm

Hello TahMiD,

Yeah, I noticed that too. One of the reasons why I want to stay away from MDL and not use it for future themes is because of the extensive "DOM manipulations" this framework does. You should never rely heavily on JS but here's one of Google's projects telling otherwise.

This issue is caused by the MDL framework main JS file material.min.js. When this file is loaded, it does something to the DOM and forces it to reload iframes (To be honest, I really have no idea how this is done. But I am sure it is caused by this file). This issue has been already discussed here https://github.com/google/material-desi ... ssues/1836 and the author promised it will be fixed in v2.0 (current version is 1.3 so this might take a while)

So if you open functions.php and comment out this line:
// Loading MDL JS
wp_enqueue_script( 'material', get_template_directory_uri() . '/js/material.min.js' );
So it becomes:
// Loading MDL JS
//wp_enqueue_script( 'material', get_template_directory_uri() . '/js/material.min.js' );
The issue will be gone but this file is important for many UX animations and it is used for other things too like form validation and expanding textboxes so, unfortunately, there is no fix for this bug as far as I know :oops:
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
paulinalarocca

New Member Rank
Posts: 1
Joined: Mon Apr 16, 2018 7:04 am
Display Name: paulinalarocca

Re: Adsense Ads, Any JavaScript, YouTube Player Loading Twice!

linkPost by paulinalarocca » Mon Apr 16, 2018 7:05 am

This is a nice and informative post Thanks!

Who is online

Users browsing this forum: No registered users and 1 guest

It is currently Mon Apr 23, 2018 1:19 pm