HTML5 Zone is brought to you in partnership with:

Hirvesh Munogee is a freelance web developer who also happens to have a passion for blogging. Hirvesh is a DZone MVB and is not an employee of DZone and has posted 177 posts at DZone. You can read more from them at their website. View Full User Profile

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

01.01.2013
| 1879 views |
  • submit to reddit

 

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 Hirvesh Munogee, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)