Skip to content

Instantly share code, notes, and snippets.

View despeset's full-sized avatar
🗃️
Not actively maintaining anything.

Daniel Espeset despeset

🗃️
Not actively maintaining anything.
View GitHub Profile
@despeset
despeset / img-alt-reveal-marklet.js
Last active December 10, 2019 19:47
Replace images that have alt attributes with their text.
Array.from(document.querySelectorAll('img[alt]:not([alt=""])')).forEach($el => {
const $div = document.createElement('div');
$div.style.display = 'inline-block';
const {width, height} = $el.getBoundingClientRect();
$div.style.width = width;
$div.style.height = height;
$div.innerText = $el.getAttribute('alt');
$el.parentNode.replaceChild($div, $el);
});
@despeset
despeset / keybase.md
Last active May 12, 2018 02:46
Keybase proof

Keybase proof

I hereby claim:

  • I am danielmendel on github.
  • I am desp (https://keybase.io/desp) on keybase.
  • I have a public key ASBa6vwYa3n3Hp5k5gw0XkB8mki194rQyFiso26aB3rLUgo

To claim this, I am signing this object:

@despeset
despeset / captureStartRender.js
Created October 16, 2013 21:19
Using requestAnimationFrame to approximate the browser's first paint time.
!function(namespace) {
// normalize requestAnimationFrame across user agents
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
}
// capture first paint
if(window.requestAnimationFrame)
requestAnimationFrame(function(){
namespace.firstAnimationFrameFired = new Date().getTime();
var s = document.createElement('script');
s.src = preload[1];
s.type = "text/cache";
document.getElementsByTagName('head')[0].appendChild(s);