Skip to content

Instantly share code, notes, and snippets.

View mstalfoort's full-sized avatar

Marc Stalfoort mstalfoort

View GitHub Profile
@remy
remy / delay-iframe.js
Created September 28, 2012 10:58
Detect whether an iframe is initialised with a width or not - some browser have a width, some don't
var iframedelay = (function () {
var iframedelay = { active : false },
iframe = document.createElement('iframe'),
doc,
callbackName = '__callback' + (+new Date);
iframe.style.height = iframe.style.width = '1px';
iframe.style.visibility = 'hidden';
document.body.appendChild(iframe);
doc = iframe.contentDocument || iframe.contentWindow.document;
@jeromeetienne
jeromeetienne / submsNow.js
Created August 25, 2012 09:56
a submillisecond version of Date.now() based on based on window.performance.now()
/**
* precise version of Date.now() -
* It provide submillisecond precision based on window.performance.now() when
* available, fall back on Date.now()
* see http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
*/
var nowSubms = (function(){
var p = window.performance || {};
if( p.now ) return function(){ return p.timing.navigationStart + p.now(); };
else if( p.mozNow ) return function(){ return p.timing.navigationStart + p.mozNow(); };