Is it a good idea to serve different jQuery versions based on conditional comments? -
with jquery 2.0 being released, wonder if there problems occurr when serving different versions of jquery ie8 , lower , other browsers use of "conditional comments":
<!doctype html> <head> <!--[if lte ie 8]> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <![endif]--> <!--[if gt ie 8]> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <![endif]--> <!--[if !ie]> --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <!-- <![endif]--> </head> <body> </body> </html>
since release notes state,
jquery 2.0 has same api jquery 1.9
i assume save take approach extensive amount of existing jquery code. missing something?
opinion type question:
my opinion
most in 2.0 same html5 exception. many "vanilla" js functions have been replaced jquery style mark-up (this observance of code) , code making use of newly implemented "standards", making incompatible older ie.
however, @ current, name-spacings same. thought is, it's not bad @ all, but, previous versions of jquery, don't expect looks 1 way in html5 browser (chrome, ff, ie9+) same in older browser. u may still want checks possible ie specifics previous versions. nothing new.
more not, blanketed jquery mark-up fine, might notice slim difference. 1 instance how ie 7 handles .animate on styles opposed how ie 9 or 10 handles them. said before, nothing new.
i design sight ready latest in standards , "back version" compatibility older browsers. because, whatever need throw "specific" in for, not amount compared rest of code. also, time finish development on something, 1 of older ones may have been expected support, may no longer issue.
if helps any, ms has announced slow steady drops of support beneath vist/ie9 on next half decade or so. expect see less , less demand older browser support. http://support.microsoft.com/gp/lifeadditionalproducts (there better article them in whitepapers, it's in email, not sure whitepapers listing online)
one other "gotchya" i've found lately, firefox becoming more microsoft. i've found trying incorporate "own standards" , pushing in opposite direction "i" consider standard development. has become more , more of issue find things "work in browsers (even ie7!), firefox!" haven't investigated enough see why ff changing much, becoming new "ie headache" development.
one prime example, css style in header having any incompleteness or css3 standards new ff engine doesn't kill entire page. off top of head, 1 issue ran (if i'm remembering correctly, few weeks ago) doing table rows , :after
. firefox 1 line in css , "boom! doa!" no js work, no styling after work. changed 1 line use combo of nth-child
, +
, had no more argument out of ff.
i used love ff, ie catching up, ms announcing drop in support "bad old carp" , mozilla switching gears fall behind (again opinion), -mozilla-
being new "behind all" browser must make "conditional" statements for.
update [6/5/13]
upon receiving new points on post, took minute review , thought share 1 other "gotchya" have found jquery name-spacing. don't know why didn't mention before, other it's kind of old , suppose assumed people know. however, due other i've given lately, i've found quite "unknown".
one older "gotchya" jquery came release of 1.7. if up, you'll see, changed major name-spacing, later became deprecated. name-spaces $.bind
, $.delegate
, , $.live
replaced easier follow name-spaces of $.on
, $.off
. of course bit of pain developers moving new required if
statement based on versions.
again, issue switching between jquery versions of 1.7+newer , > 1.7!
if choose flip between newer , older jquery, suggest wrap delegated functions in named method. can called $(document).on("event", "element", functionname)
. don't forget parameter of named function event
. also, if missed solution , need (the if
statement), it's simple follows:
if ($.fn.on) { /* * using jquery ver >= 1.7 * work necessary using: * $(document).on("event", "selector", callback) */ } else { /* * using jquery ver < 1.7 * work necessary using like: * $(document).live("event", "selector", callback) */ }
Comments
Post a Comment