Over a million developers have joined DZone.

Conditionizr - A jQuery Plugin For Conditional-Free Legacy, Retina, Script & Style Loading

DZone 's Guide to

Conditionizr - A jQuery Plugin For Conditional-Free Legacy, Retina, Script & Style Loading

· Web Dev Zone ·
Free Resource


Conditionizr is a jQuery plugin which allows you to detect several end-user’s browser and environment properties and then serve specific conditional JavaScript and CSS files to them.

What Problem Does It Solve?

Prior to Conditionizr, if you wanted to serve some conditional JavaScript and CSS files, you would wrap those script and stylesheet tags with conditional HTML tags.  Those scripts would load if the browser matched the rules of the conditional HTML tags.

Now with Conditionizr, there is no need to soil your markup with conditional HTML tags, Conditionizr takes care of this process.

What’s Under The Hood?

Using Conditionizr, you get to load custom scripts and polyfills on  a per browser policy.  Additionally, Conditionizr gives you the ability to load JavaScript and CSS files for a range of browsers lower than a specified version.  Let’s say you’ve got a polyfill script which is need for browser prior to IE9, you could use the setting option provided in Conditionizr to load that polyfill for all those browsers in a single line of code.

Conditionizr also allows you to detect the platform which your end user is using – it could be Mac OS X, Windows, Linux or Unix and then lets you specify specific assets to load for those platforms.  This is especially useful when the same browser has display quirk on different platforms. Conditionizr steps in and allows you to solve this problem as well.

What’s more with Conditionizr is that it also allows you to pixel ratios of end-user browsers and allows you to serve retina-ready assets for your website to your users.

Conditionizr is also Modernizr compatible and is build using to be as reliable in browser sniffing as possible, using methods similar to what’s used in Google Analytics.  Conditionizr weight in at only 3KB and is sure to be an asset in your web developer’s toolbox.

Requirements: jQuery
Demo: http:/ / conditionizr. com/
License: MIT License


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}