Skip to content

Instantly share code, notes, and snippets.

@srinathweb
Created August 14, 2015 11:53
Show Gist options
  • Select an option

  • Save srinathweb/d1ec3a2fa8c2fbe145ad to your computer and use it in GitHub Desktop.

Select an option

Save srinathweb/d1ec3a2fa8c2fbe145ad to your computer and use it in GitHub Desktop.
favicon
http://stackoverflow.com/questions/5199902/isnt-it-silly-that-a-tiny-favicon-requires-yet-another-http-request-how-to-mak
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Suppress browser request for favicon.ico -->
<link rel="shortcut icon" href="#">
<script src="script.js"></script>
...
script.js
var favIcon = "\
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABrUlEQVR42mNkwAOepOgxMTD9mwhk\
[...truncated for brevity...]
IALgNIBUQBUDAFi2whGNUZ3eAAAAAElFTkSuQmCC";
var docHead = document.getElementsByTagName('head')[0];
var newLink = document.createElement('link');
newLink.rel = 'shortcut icon';
newLink.href = 'data:image/png;base64,'+favIcon;
docHead.appendChild(newLink);
/* Other JS would normally be in here too. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment