Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

history.pushState in Chrome make favicon request

Code :

var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname +"?"+ queryStr; 
window.history.pushState({path:newurl},'',newurl)

Current scenario :

Every time when window.history.pushState() is invoked favicon requests occur rapidly.It makes network request for favicon on every call of this function.

Expected scenario :

The favicon should be loaded only once on page load, I would not expect the favicon load on every request of window.history.pushState().

Favicon paths are link like this in HTML page :

<!-- Favicon -->
  <link rel="icon" type="image/png" href="../img/icon/favicon-16x16.png" sizes="16x16">
  <link rel="icon" type="image/png" href="../img/icon/favicon-32x32.png" sizes="32x32">
  <link rel="icon" type="image/png" href="../img/icon/favicon-96x96.png" sizes="96x96">
like image 674
Creative Learner Avatar asked Mar 19 '16 16:03

Creative Learner


1 Answers

It looks like a bug in Chromium browsers. See this open issue.

But there seems to be a workaround if you use base64 image as href the request won't occur.

<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">

See this question.

like image 193
Ankit Singh Avatar answered Oct 18 '22 22:10

Ankit Singh