Skip to content

Commit

Permalink
weaker detect for webgl to avoid potentially expensive context creati…
Browse files Browse the repository at this point in the history
…on. fixes Modernizr#511
  • Loading branch information
paulirish committed Mar 15, 2012
1 parent 5c3e0fe commit ebdd20c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,19 +447,13 @@ window.Modernizr = (function( window, document, undefined ) {
return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
};

// this test initiates a new webgl context.
// webk.it/70117 is tracking a legit feature detect proposal
// webk.it/70117 is tracking a legit WebGL feature detect proposal

// We do a soft detect which may false positive in order to avoid
// an expensive context creation: bugzil.la/732441

tests['webgl'] = function() {
try {
var canvas = document.createElement('canvas'),
ret;
ret = !!(window.WebGLRenderingContext && (canvas.getContext('experimental-webgl') || canvas.getContext('webgl')));
canvas = undefined;
} catch (e){
ret = false;
}
return ret;
return !!window.WebGLRenderingContext;
};

/*
Expand Down

0 comments on commit ebdd20c

Please sign in to comment.