Skip to content

Instantly share code, notes, and snippets.

@ahvonenj
Created October 19, 2015 12:55
Show Gist options
  • Save ahvonenj/8e2eef80590e200dd297 to your computer and use it in GitHub Desktop.
Save ahvonenj/8e2eef80590e200dd297 to your computer and use it in GitHub Desktop.
Invalid src buster
// Scans through whole HTML document and tries to find src or css url-rules that are faulty
// These faulty / empty rules can cause Google Chrome to load a webpage multiple times
// First run this whole script in developer console and then print out contents of bustedNullSrcs array
// The array contents give hints as to what might cause the Chrome multiple page load bug
var bustedNullSrcs = [];
(function($)
{
bustedNullSrcs.length = 0;
$('*').each(function()
{
var $self = $(this);
var id = $self.attr('id');
var src = $self.attr('src');
var url = $self.css('background-image');
var url2 = $self.css('background');
var url2gex = null;
var gex = /(?:url\((.*)\))/gi;
if(gex.test(url2))
{
url2gex = url2.match(gex)[0];
}
var bustedObject =
{
id: id,
src: src,
url: url,
url2: url2
}
if(src == "#" || src == "" || url == "" || url2gex == "''" || url2gex == '""' || url2gex == '')
bustedNullSrcs.push(bustedObject);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment