has("builds")
-
Upload
peter-higgins -
Category
Technology
-
view
563 -
download
2
Transcript of has("builds")
![Page 1: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/1.jpg)
HAS(“BUILDS”)@dojoconf :: 16/17 Sept 2011 :: Peter Higgins
Monday, September 19, 2011
![Page 2: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/2.jpg)
Me, Briefly.
Dojo Toolkit Project Lead
JavaScript Engineer @joost / Adconion
Blogs Infrequently :: http://higginsforpresident.net
Codes @GitHub :: http://github.com/phiggins42
Twitter: @phiggins
Beer Drinking Expert
Monday, September 19, 2011
![Page 3: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/3.jpg)
THE HISTORY... and motivation
Monday, September 19, 2011
![Page 4: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/4.jpg)
//>>webkitMobile
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);/*//>>excludeEnd("webkitMobile");//>>includeStart("webkitMobile", kwArgs.webkitMobile);["indexOf", "lastIndexOf", "forEach", "map", "some", "every", "filter"].forEach( function(name, idx){ dojo[name] = function(arr, callback, thisObj){ if((idx > 1) && (typeof callback == "string")){ callback = new Function("item", "index", "array", callback); } return Array.prototype[name].call(arr, callback, thisObj); } });//>>includeEnd("webkitMobile");//>>excludeStart("webkitMobile", kwArgs.webkitMobile);*///>>excludeEnd("webkitMobile");
Monday, September 19, 2011
![Page 5: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/5.jpg)
/sigh
Sloppy code
Error prone
Difficult debugging / Build required
Single specific platform
Monday, September 19, 2011
![Page 6: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/6.jpg)
embed.js / Uxebu
different direction, same idea: minimal bytes
per-function modules
minimal API surface (a la carte)
Dojo based, but not Dojo
Monday, September 19, 2011
![Page 7: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/7.jpg)
Modernizr
new features, not old bugs.
up front testing, all tests always
dojo.uacss-style HTML classes
Monday, September 19, 2011
![Page 8: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/8.jpg)
dojo-fd
dojo/trunk branch
Pure feature detection
first has() sighting
Monday, September 19, 2011
![Page 9: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/9.jpg)
has.js
Feature detection API
Feature + Future tests available
Minimal bytes / No initial overhead
Simple API for configurable code paths
Generic / Agnostic
Monday, September 19, 2011
![Page 10: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/10.jpg)
has() in Dojo: old “sniff”
require(["dojo/_base/sniff"], function(has){
has.add("some-magic", function(){ // randomly return true or false return Math.random() > 0.5; });
if(has("some-magic")){ // do it this way }else{ // do it this way }
});
Monday, September 19, 2011
![Page 11: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/11.jpg)
has() in Dojo: plugin
define([ "dojo/has!native-array!mylib/Thinger!mylib/AltThinger"], function(Thinger){
// Thinger is mylib/Thinger return if has("native-array") // otherwise is mylib/AltThinger // ideally they have the same API (a la embedjs)
});
Monday, September 19, 2011
![Page 12: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/12.jpg)
Builder
hasMap in profile
variable substitution
dead path removal
Monday, September 19, 2011
![Page 13: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/13.jpg)
Builder
mylib.trim = has("string-trim") ? function(str){ return str.trim(); } : function(str){ /* regexp/replace that guy */ };
// build = { “string-trim”:“true” } becomes:
my.trim = true ? function(a){ return a.trim(); } : function(a){ /* ... */ }; // becomes:
my.trim = function(a){ return a.trim(); }
Monday, September 19, 2011
![Page 14: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/14.jpg)
Misc. Building
RequireJS
Dojo 1.7
ua-optimize https://github.com/kriszyp/ua-optimized
Monday, September 19, 2011
![Page 15: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/15.jpg)
Detect or Assume
has() is agnostic
write own tests
document historic truth
limit impact of testing in production
10ms - 1800ms
Monday, September 19, 2011
![Page 16: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/16.jpg)
WHEREdoes this leave us?
Monday, September 19, 2011
![Page 17: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/17.jpg)
AAAAND THANKS.I promise I’m done talking.
Monday, September 19, 2011
![Page 18: has("builds")](https://reader033.fdocuments.in/reader033/viewer/2022042814/555a6670d8b42ae7218b4b0c/html5/thumbnails/18.jpg)
Me, again:
http://dante.dojotoolkit.org
http://higginsforpresident.net
http://twitter.com/phiggins
http://github.com/phiggins42
phiggins @ irc.freenode.net
Questions?
Monday, September 19, 2011