admin管理员组

文章数量:1399754

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">

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">
Share Improve this question edited Aug 29, 2022 at 21:39 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Mar 19, 2016 at 16:03 Rohìt JíndalRohìt Jíndal 27.2k15 gold badges77 silver badges132 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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.

本文标签: javascripthistorypushState in Chrome make favicon requestStack Overflow