Comments on: Using Modernizr to detect HTML5 features and provide fallbacks https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/ helping you implement HTML5 today Thu, 28 Jul 2016 17:36:34 +0000 hourly 1 By: Adrián https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-175521 Thu, 31 Jul 2014 09:58:02 +0000 http://html5doctor.com/?p=4371#comment-175521 Hello, first sorry for my English, I’m working on a web application, the case problem is I have a date with the guy in the safari browser. I need to be in date format (dd-mm-yyyy), and tested with the example of your article but I can not move, so I ask for help if you can help me with this. Thanks in advance.

]]>
By: louie @ Green Box https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-48600 Fri, 07 Mar 2014 12:35:07 +0000 http://html5doctor.com/?p=4371#comment-48600 That is handy for detecting html 5 features in the browser. great they included the shiv for old versions of Internet explorer also.

]]>
By: Jeffrey Barke https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-36444 Mon, 15 Jul 2013 21:54:16 +0000 http://html5doctor.com/?p=4371#comment-36444 @html5Doctor,
@bouks,

I just set up a couple of demos to test the example code, and I ran into a problem with Modernizr 2.6.2 and the latest version of Chrome. The complete callback of Modernizr.load is called regardless of the test results. This causes an error when jQuery is not loaded, so I have two alternatives to the example you posted:


Modernizr.load({
test: Modernizr.inputtypes.date,
nope: [
'js/jquery.min.js',
'js/jquery-ui.min.js'
],
complete: function () {
if (window.jQuery) {
jQuery('input[type=date]').datepicker({
dateFormat: 'yy-mm-dd'
});
}
}
});

In this case, we simply add a test for the presence of jQuery to the complete callback.


Modernizr.load({
test: Modernizr.inputtypes.date,
nope: [
'js/jquery.min.js',
'js/jquery-ui.min.js'
],
callback: {
'js/jquery-ui.min.js': function () {
$('input[type=date]').datepicker({
dateFormat: 'yy-mm-dd'
});
}
}
});

In this case, I use the callback property with the “js/jquery-ui.min.js” key. Since “js/jquery-ui.min.js” is only loaded when the test fails, we don’t need the conditional.

Finally, as bouks mentions, possibly you are certain that jQuery and jQuery UI are already on the page. In that case you don’t need the Modernizr loader a’tall, just the test:


if (!Modernizr.inputtypes.date) {
jQuery('input[type=date]').datepicker({
dateFormat: 'yy-mm-dd'
});
}

My demos are located at:
http://jeffreybarke.net/demos/modernizr/date-picker-loader-1.html
http://jeffreybarke.net/demos/modernizr/date-picker-loader-2.html
http://jeffreybarke.net/demos/modernizr/date-picker-loader-3.html

]]>
By: bouks https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-36170 Wed, 10 Jul 2013 15:11:48 +0000 http://html5doctor.com/?p=4371#comment-36170 Better solution for your example of detecting input type date and datepicker.

Often you have already included jquery and jquery ui for other things in the website.
In this case, your example will not work and in a capable browser you will have both native and jquery datepicker.

The solution :


if (!Modernizr.inputtypes.date) {
//optional
Modernizr.load(['/js/jquery.ui.datepicker-yourlangage.js']);

$('input[type=date]').datepicker({
dateFormat: 'yy-mm-dd',
minDate: "-100Y",
maxDate: "-18Y",
changeMonth: true,
changeYear: true
});
}

]]>
By: Nitin https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-29448 Sat, 15 Dec 2012 01:35:49 +0000 http://html5doctor.com/?p=4371#comment-29448 Thanks it was one of the best explainations

]]>
By: cwebba1 https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-29310 Tue, 20 Nov 2012 19:20:30 +0000 http://html5doctor.com/?p=4371#comment-29310 I’m VERY excited by this article, planning to try your example of loading JQuery within Modernizer after previous failed attempts.
Please clarify about the “Modernizer is same as Yepnope” statement, which I see oft repeated. Specifically I want to know about your example of yepnope properties – I see the same switch of reference in every tutorial – can I use “modernizer” instead of “yepnope” with those property patterns in Modernizr?
(Is “modernizr ([{ callback:” OK to use?)
Are the two names the same thing within Modernizr? I cannot be sure whether you are saying to load the yepnope program or to use “yepnope” as part of the modernizr syntax? Please nail this down.
Another thing that I cannot find is an example of combining two javascript polyfills within one “script.js” file. Mr. Doubting Thomas here wants to SEE how it looks. Every tutorial skips ahead to “too hard to do so use a Concatenator / minifier” and skips over this critical bit of information.
The third big bit of info that I’m wondering about is about the path to polyfills to call within Modernizr. If I combine multiple polyfills into one scripts.js file, do I just call that one scripts.js file for every time I need a polyfill? Wouldn’t that load the entire scripts.js file multiple times? Or should I not combine/minify scripts when using Modernizr and just keep each one separate?

]]>
By: Alastair https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-28960 Tue, 25 Sep 2012 08:58:31 +0000 http://html5doctor.com/?p=4371#comment-28960 I think at this point, anyone who deliberately turns off Javascript deserves exactly what they get. My belief is there is not enough tinfoil in the world for the hats of those who browse the internet with Javascript turned off and certainly those people aren’t visiting the websites I develop.

]]>
By: Alex https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-28891 Wed, 29 Aug 2012 10:17:33 +0000 http://html5doctor.com/?p=4371#comment-28891 Nice little article – great high level description of some of the really useful features of this tool – thanks.

]]>
By: JeffNunn https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-27876 Mon, 11 Jun 2012 19:30:14 +0000 http://html5doctor.com/?p=4371#comment-27876 The web runs on Javascript and has run on Javascript since the early 2000’s. If someone has their Javascript turned off, they have essentially turned off the web altogether. Might as well turn of CSS and HTML while you’re at it. I don’t waste my time testing for turned off JS.

While testing for compatibility with SCREENREADERS is related, it is not the same thing as testing for people who have turned off JS

]]>
By: Nick https://stevefaulkner.github.io/html5doctored/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comment-27831 Mon, 11 Jun 2012 09:53:20 +0000 http://html5doctor.com/?p=4371#comment-27831 Anyone who is browsing the web with a browser capable of javascript, yet with it turned off, is either a retard, or is using that computer for something that would end in them not visiting random websites…

Every device nowadays supports javascript, so you can count on javascript being enabled for your site… or your site is for retards… either way…

]]>