Skip to content

Instantly share code, notes, and snippets.

@gruber
Created December 4, 2012 02:45
Show Gist options
  • Save gruber/4200065 to your computer and use it in GitHub Desktop.
Save gruber/4200065 to your computer and use it in GitHub Desktop.
Fix Antialiasing
// javascript:var%20style%20=%20%27*%20{-webkit-font-smoothing:%20auto%20!important}%27;var%20link_element%20=%20document.createElement(%27link%27);link_element.rel%20=%20%27stylesheet%27;link_element.href%20=%20%27data:text/css,%27%20+%20escape(style);document.getElementsByTagName(%22head%22)[0].appendChild(link_element);
var style = '* {-webkit-font-smoothing: auto !important}';
var link_element = document.createElement('link');
link_element.rel = 'stylesheet';
link_element.href = 'data:text/css,' + escape(style);
document.getElementsByTagName("head")[0].appendChild(link_element);
@potch
Copy link

potch commented Dec 4, 2012

I did some research, and there's an awesome API called insertAdjacentHTML that works in Safari 4+. Using that API, this is as easy as:

document.head.insertAdjacentHTML('beforeend', '<style> * { -webkit-font-smoothing: auto !important } </style>');

How cool is that??

@thecrypticace
Copy link

Wow, nicely done potch! I've never even seen that API before. O_o. That totally bests my snippet. bows to the leader of the people-who–actually–lookup–API–goodies

That snippet is completely . ;)

@thecrypticace
Copy link

Oops, forgot to wrap the tag… the joke was: That snippet is completely <meta>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment