history.pushState in Chrome make favicon request

孤街浪徒 提交于 2019-12-05 14:04:36

问题


code :

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

current scenario :

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

expected scenario :

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

Any immediate help will be highly appreciable. Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/36103904/history-pushstate-in-chrome-make-favicon-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!