Over a million developers have joined DZone.

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

· Web Dev Zone

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.


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

Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.


Published at DZone with permission of Hirvesh Munogee, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}