Skip to content

Instantly share code, notes, and snippets.

Avatar
🗃️
Not actively maintaining anything.

Daniel Espeset danielmendel

🗃️
Not actively maintaining anything.
View GitHub Profile
@danielmendel
danielmendel / img-alt-reveal-marklet.js
Last active Dec 10, 2019
Replace images that have alt attributes with their text.
View img-alt-reveal-marklet.js
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);
});
@danielmendel
danielmendel / keybase.md
Last active May 12, 2018
Keybase proof
View keybase.md

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:

@danielmendel
danielmendel / captureStartRender.js
Created Oct 16, 2013
Using requestAnimationFrame to approximate the browser's first paint time.
View captureStartRender.js
!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();
View prefetching-example.js
var s = document.createElement('script');
s.src = preload[1];
s.type = "text/cache";
document.getElementsByTagName('head')[0].appendChild(s);