Modernizr, JavaScript Library to Create All-Terrain Web Pages
When you develop digital projects you should always remember – what you see on the browser is what there is. It doesn't matter which backend or styles your web page has if it the rendered result on the browser is not what you expected. The JavaScript library Modernizr prevents this type of disappointment: it is the best tester for determining which of the project's characteristics are supported by each browser.
Specifically, Modernizr reviews 18 CSS3 style characteristics and 40 additional characteristics related to the HTML document, especially HTML5, the latest available version. This is interesting because more recent browsers can run resources which are out of reach for older browsers. The idea is to utilize the former's advantages while still catering to the latter. As a consequence, the design is adjusted to the user's experience in all browsers. And you can create all-terrain digital projects.
How to install Modernizr and Modernizr tools
To download and install the library:
– First, download the file with Modernizr's source code. The code is in JavaScript language and offers two variables: Development, a full script with all of the library's functionalities, unzipped, and perfect for development; and Production, specific libraries for web page testing once the pages have been uploaded to the production server. It is recommended that you only install the modules you are going to use. This is the full list of Modernizr features and modules.
– To use this JavaScript library, you need to add the Modernizr script to the page's <head>, right after the site's CSS style declarations. First the styles and then the library are loaded. This is the script you need to add to the project's <head>:
<script src=”modernizr.js"></script>
Modernizr mostly uses two tools to detect which specific functionalities are available on each browser:
1. JavaScript object: after the Modernizr library has been installed and loaded, the JavaScript object allows you to detect which project functionalities are supported by each browser both in HTML language and CSS styles. This detection uses theBoolean variables true and false. True means that the browser supports the feature; false means that it doesn't.
if (Modernizr.awesomeNewFeature) { showOffAwesomeNewFeature(); } else { getTheOldLameExperience(); }
Here are two practical cases taken from the theoretical example above. The first tests whether or not the user's browser supports our project's touch events. The second detects whether shadows can be applied:
if (Modernizr.touch){
//the browser supports touch events
} else {
//the browser does not support touch events
}
if (Modernizr.boxshadow) { // Shadows can be applied! } else { // box-shadow is not available }
2. CSS classes: the library automatically loads all CSS classes that correspond to the style functionalities recognized by a modern browser – canvas, touch events, shadows, geolocation, video, audio, gradients, opaqueness, image frames, storage, animation, database features, etc. This would be the standard HTML document with these classes:
Most modern functionalities in HTML5 and CSS3 are run by modern browsers. That is not the case with old browsers though. For older browsers, developers must create the classes necessary to reproduce the functionality: use the classic CSS to do this.
If you wish to add shadow and Modernizr didn't install this property automatically because the browser is older, add it manually:
Polyfill libraries and the Modernizr.load() method
Modernizr offers a method for developers to perform on-demand load of libraries and plugins that increase the functionalities of older browsers. The library only loads if the user visits a page with a specific style that is not available on the browser.
This is achieved by loading one of these plugins or polyfills using Modernizr.load(). In this way, you keep the UX of older browsers.
This is done as follows:
– Modernizr allows you to detect whether or not the functionality is available within the user's browser. If the property is not available, the Modernizr.load() method loads the specific polyfill for the function.
– How can I use the Modernizr.load() method to add libraries? The code is simple, and in this case it includes geolocation:
Banco Bilbao Vizcaya Argentaria, S.A. owner of this portal uses cookies and/or similar technologies of its own and third parties for the purposes of personalization, analytics, behavioral advertising or advertising related to your preferences based on a profile prepared from your browsing habits (e.g. pages visited). If you wish to obtain more detailed information, consult our Cookies Policy.
Cookie settings panel
These are the advanced settings for first-party and third-party cookies. Here you can change the parameters that will affect your browsing experience on this website.
Technical Cookies (required)
These cookies are used to give you secure access to areas with personal information and to identify you when you log in.
Name
Owner
Duration
Description
gobp.lang
BBVA
1 month
Language preference
aceptarCookies
BBVA
1 year
Configuration Accepted Cookies
_abck
BBVA
1 year
Helps protect against malicious website attacks
bm_sz
BBVA
4 hours
Helps protect against malicious website attacks
ADRUM_BTs
Salesforce Marketing Cloud
Session
Required for monitoring of the service, inherent to SFMC
ADRUM_BT1
Salesforce Marketing Cloud
Session
Required for monitoring of the service, inherent to SFMC
ADRUM_BTa
Salesforce Marketing Cloud
Session
Required for monitoring of the service, inherent to SFMC
ADRUM_BT
Salesforce Marketing Cloud
Session
Required for monitoring of the service, inherent to SFMC
xt_0d95e
Salesforce Marketing Cloud
Session
Remember user preferences (if any)
__s9744cdb192d044faa1bf201d29fafd1e
Salesforce Marketing Cloud
Session
Remember user preferences (if any)
wpml_browser_redirect_test
WPML
Session
Text translation in the portal
wp-wpml_current_language
WPML
24 hours
Text translation in the portal
Analytics Cookies
They are used to track the activity or number of visits anonymously. Thanks to them we can constantly improve your browsing experience
Your browsing experience is constantly improving.
With your selection, we cannot offer you a continuously improved browsing experience.
Name
Owner
Duration
Description
AMCV_***
Adobe Analytics
Session
Unique Visitor IDs used in Cloud Marketing solutions
AMCVS_***
Adobe Analytics
2 years
Unique Visitor IDs used in Cloud Marketing solutions
demdex (safari)
Adobe Analytics
180 days
Create and store unique and persistent identifiers
sessionID
Adobe Analytics
Session
Launch's internal cookie used to identify the user
gpv_URL
Adobe Analytics
Session
Adobe Analytics plugin: getPreviousValue Capture the value of a certain variable in the following page view, in this case the prop1
gpv_level1
Adobe Analytics
Session
Cookie used to store the DataLayer levl1 of the previous page.
gpv_pageIntent
Adobe Analytics
Session
Cookie used to store the pageIntent of the previous page.
gpv_pageName
Adobe Analytics
Session
Cookie used to store the pagename of the previous page.
aocs
Adobe Analytics
Session
Cookie that stores the first values collected at the beginning of a process.
TTC
Adobe Analytics
Session
Cookie used to store the time between the App Page Visit event and the App Completed event.
TTCL
Adobe Analytics
Session
Cookie used to store the time between the LogIn event and App Completed.
s_cc
Adobe Analytics
Session
Determine if cookies are active
s_hc
Adobe Analytics
Session
Cookie used by Adobe for analytical purposes
s_ht
Adobe Analytics
Session
Cookie used by Adobe for analytical purposes
s_nr
Adobe Analytics
2 years
Determine the number of user visits
s_ppv
Adobe Analytics
Permanent
Adobe Analytics plugin: getPercentPageViewed Determine what percentage of the page a user views
s_sq
Adobe Analytics
Session
ClickMap/ActivityMap features
s_tp
Adobe Analytics
Session
Cookie used by Adobe for analytical purposes
s_visit
Adobe Analytics
2 years
Cookie used by Adobe to know when a session has been started.
Advertising Cookies
They allow the advertising shown to you to be customized and relevant to you. Thanks to these cookies, you will not see ads that you are not interested in.
The advertising is customized to you and your preferences.
Your choice means you will not see customized ads, only generic ones.
Name
Owner
Duration
Description
OT2
VersaTag
90 days
VersaTag Cookie used to store a user id and the number of user visits.
u2
VersaTag
90 days
VersaTag Cookie where the user ID is stored
TargetingInfo 2
MediaMind
1 year
Cookie that serves to assign a unique random number that generates MediaMind.
Customization Cookies
These cookies are related to general features such as the browser you use.
Your experience and content have been customized.
With your selection, we cannot offer you a continuously improved browsing experience.
Name
Owner
Duration
Description
mbox
Adobe Target
9 days
Cookie used by Adobe Target to test user experience customization.
Looks like you’re browsing from MexicoSpainArgentinaPeruColombiaBelgiumChileUSAFranceHong KongItalyPortugalUnited KingdomTurkeyUruguayVenezuelaAlemania, so let’s show you the custom content for your
location. Change
Select a country
In order to access the private area and corresponding sandbox, select the country of the APIs you want to use.