javascript - Modernizr yepnope conditional callback only when false -


i'd appreciate thoughts , advice on best way this. id execute tiny script — not worth loading — if modernizr test false. solution looks bit clunky.

        modernizr.load({             test: modernizr.inlinesvg,             yep : 'js/funky-svg-animation.js',             complete : function () {                 if (!modernizr.inlinesvg){                     console.log('stuff when false');                 }             },         }); 

edit: based on comments, efficient approach:

        if (modernizr.inlinesvg){             $(body).append('<script src="js/funky-svg-animation.js"><\/script>')         } else {             console.log('stuff when false');         } 

or there problems approach?

in modernizr have yep , nope if browser testing doesn't support feature need, nope can stuff.

modernizr.load({       test: modernizr.inlinesvg,       yep : 'js/funky-svg-animation.js',       nope : 'path/to/your/script.js'       },   }); 

where path/to/your/script.js just:

console.log('stuff when false'); 

this default behavior of yenope, supposed load external resources if needed.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -