Your SlideShare is downloading. ×
0
HAS(“BUILDS”)                             @dojoconf :: 16/17 Sept 2011 :: Peter HigginsMonday, September 19, 2011
Me, Briefly.                 Dojo Toolkit Project Lead                 JavaScript Engineer @joost / Adconion              ...
THE HISTORY                                ... and motivationMonday, September 19, 2011
//>>webkitMobile            //>>excludeStart("webkitMobile", kwArgs.webkitMobile);            /*            //>>excludeEnd...
/sigh                 Sloppy code                 Error prone                 Difficult debugging / Build required        ...
embed.js / Uxebu                 different direction, same idea: minimal bytes                 per-function modules       ...
Modernizr                 new features, not old bugs.                 up front testing, all tests always                 d...
dojo-fd                 dojo/trunk branch                 Pure feature detection                 first has() sightingMonda...
has.js                 Feature detection API                 Feature + Future tests available                 Minimal byte...
has() in Dojo: old “sniff”               require(["dojo/_base/sniff"], function(has){                     has.add("some-ma...
has() in Dojo: plugin               define([                   "dojo/has!native-array!mylib/Thinger!mylib/AltThinger"     ...
Builder                 hasMap in profile                 variable substitution                 dead path removalMonday, S...
Builder           mylib.trim = has("string-trim") ?               function(str){ return str.trim(); } :               func...
Misc. Building                 RequireJS                 Dojo 1.7                 ua-optimize https://github.com/kriszyp/u...
Detect or Assume                 has() is agnostic                 write own tests                 document historic truth...
WHERE                             does this leave us?Monday, September 19, 2011
AAAAND THANKS.                                 I promise I’m done talking.Monday, September 19, 2011
Me, again:                 http://dante.dojotoolkit.org                 http://higginsforpresident.net                 htt...
Upcoming SlideShare
Loading in...5
×

has("builds")

571

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
571
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "has("builds")"

  1. 1. HAS(“BUILDS”) @dojoconf :: 16/17 Sept 2011 :: Peter HigginsMonday, September 19, 2011
  2. 2. 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 ExpertMonday, September 19, 2011
  3. 3. THE HISTORY ... and motivationMonday, September 19, 2011
  4. 4. //>>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
  5. 5. /sigh Sloppy code Error prone Difficult debugging / Build required Single specific platformMonday, September 19, 2011
  6. 6. embed.js / Uxebu different direction, same idea: minimal bytes per-function modules minimal API surface (a la carte) Dojo based, but not DojoMonday, September 19, 2011
  7. 7. Modernizr new features, not old bugs. up front testing, all tests always dojo.uacss-style HTML classesMonday, September 19, 2011
  8. 8. dojo-fd dojo/trunk branch Pure feature detection first has() sightingMonday, September 19, 2011
  9. 9. has.js Feature detection API Feature + Future tests available Minimal bytes / No initial overhead Simple API for configurable code paths Generic / AgnosticMonday, September 19, 2011
  10. 10. 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
  11. 11. 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
  12. 12. Builder hasMap in profile variable substitution dead path removalMonday, September 19, 2011
  13. 13. 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
  14. 14. Misc. Building RequireJS Dojo 1.7 ua-optimize https://github.com/kriszyp/ua-optimizedMonday, September 19, 2011
  15. 15. Detect or Assume has() is agnostic write own tests document historic truth limit impact of testing in production 10ms - 1800msMonday, September 19, 2011
  16. 16. WHERE does this leave us?Monday, September 19, 2011
  17. 17. AAAAND THANKS. I promise I’m done talking.Monday, September 19, 2011
  18. 18. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×