Hi Everybody and Happy New Year.
My new website index and some internal sections seem to load twice for some reason. The effect lasts just a second or less, and consists in a flickering to a blank white screen after the page has already loaded. It loads and then flickers to a blank page for an instant to load again.
After some testing, I have found out that the cause is the following jQuery code:
(function($){
var jump=function(e)
{
if (e){
e.preventDefault();
var target = $(this).attr("href");
}else{
var target = location.hash;
}
$('html,body').animate(
{
scrollTop: $(target).offset().top
},1000,function()
{
location.hash = target;
});
}
$('html, body').hide()
$(document).ready(function()
{
$('a[href^=\\#]').bind("click", jump);
if (location.hash){
setTimeout(function(){
$('html, body').scrollTop(0).show()
jump()
}, 0);
}else{
$('html, body').show()
}
});
})(jQuery)
and this file loaded from Google
https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.js
I am absolutely sure cos the problem is solved by removing the link or de code from the page, and there is no problem with the pages without that code.
By the way, the issue appears just with Samsung browser, mobile Chrome and some others. Not many to tell the truth, and only in mobile phones and some devices.
Probably it has something to do with other problem:
https://www.sitepoint.com/community/t/problem-after-migration-to-latest-jquery-version/343608
Maybe the display:none property works for just a second before being removed. I am not sure.