Page 1 of 1

Adsense Ads, Any JavaScript, YouTube Player Loading Twice!

Posted: Fri Apr 13, 2018 8:25 pm
by TahMiD
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!

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

Posted: Fri Apr 13, 2018 8:39 pm
by TahMiD
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.

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

Posted: Sat Apr 14, 2018 11:30 pm
by admin
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: