JavaScript shell scripting

38,974 views

Published on

Published in: Technology
2 Comments
13 Likes
Statistics
Notes
  • write JavaScript everywhere
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Here’s the video parts of which I showed in the presentation:
    <br /><object type="application/x-shockwave-flash" data="http://www.youtube.com/v/38rpb5gUhjk?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" width="350" height="288"><param name="movie" value="http://www.youtube.com/v/38rpb5gUhjk?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><embed src="http://www.youtube.com/v/38rpb5gUhjk?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" width="350" height="288" type="application/x-shockwave-flash"></embed></object>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
38,974
On SlideShare
0
From Embeds
0
Number of Embeds
31,516
Actions
Shares
0
Downloads
72
Comments
2
Likes
13
Embeds 0
No embeds

No notes for slide

JavaScript shell scripting

  1. 1. JavaScript is everywhere #42:! C:> WSH !
  2. 2. Stoyan!
  3. 3. Programming!
  4. 4. JavaScript!
  5. 5. ... iseverywhere!
  6. 6. On the server!
  7. 7. Mobile!
  8. 8. Desktop!
  9. 9. Browserextensions!
  10. 10. Photoshop!
  11. 11. Form validation too!!
  12. 12. Shell scripting!
  13. 13. In Windows!
  14. 14. WSH: WindowsScripting Host!
  15. 15. C:>edit hello.js!
  16. 16. var a = "Hello",! b = " WSH!",! c = a + b;!!WScript.Echo(c);!
  17. 17. C:>cscript hello.js!Hello WSH!!C:>wscript hello.js!
  18. 18. Open apps!
  19. 19. var ie = new ActiveXObject! ("InternetExplorer.Application");!ie.Visible = true;!ie.navigate(yahoo.com);!
  20. 20. Firefox? !
  21. 21. HTTPWatch!
  22. 22. Speed!
  23. 23. 1. Fix with YSlow !
  24. 24. 2. No regressions!
  25. 25. Monitor!
  26. 26. Set limits!
  27. 27. e.g.!max 2 scripts!max 2 styles!max 9 images!max 0 redirects!
  28. 28. ScriptingHTTPWatch!
  29. 29. var http = new ActiveXObject! ("HTTPWatch.Controller"),! ie = http.IE.New(),! ff = http.Firefox.New();!
  30. 30. // browser cache!ie.clearCache();!!// show HTTPWatch!ie.OpenWindow(false);!
  31. 31. ie.Record();!ie.GotoUrl("yahoo.com");!http.Wait(ie, -1);!ie.Stop();!!ie.CloseBrowser();!
  32. 32. new HTTPWatch()http://github.com/stoyan/etc/!
  33. 33. var http = new HTTPWatch(ff);!http.go(search.yahoo.com);!http.done();!
  34. 34. [video]!
  35. 35. var har = http.toHAR();!har = eval(( + har + ));!!print(har.log.browser.name);!print(har.log.browser.version);!print(# requests: );!print(har.log.entries.length);!
  36. 36. Internet Explorer 6.0.29...!# requests: 10!!Firefox 3.5.6!# requests: 15!
  37. 37. [video]!
  38. 38. var comps =! http.getComponentsByType();!!for (var i in comps) {! print(i);! print(comps[i].length);!}!
  39. 39. redirect: 1!text/html: 3!image/gif: 4!image/png: 3!text/javascript: 1!
  40. 40. But wait...!
  41. 41. What about DOM?!
  42. 42. [video]!
  43. 43. var http = new HTTPWatch();!http.go(search.yahoo.com);!!var d = http.watch.container.document;!!print(d! ! .getElementsByTagName(*)! ! .length);!!print(d! ! .documentElement! ! .innerHTML);!
  44. 44. require(statz.js);!!var doc = http.watch! ! ! .container.document;!var html = http.har.log! ! ! .entries[0]! ! ! .response.content.text;!!var out = statz(document, html);!print(out.join("n"));!
  45. 45. JS attributes (e.g. onclick): 1207 bytes!CSS style attributes: 883!Inline JS: 5243!Inline CSS: 5015!All innerHTML: 17283!# DOM elements: 134!!Total size: 14124 bytes!Content size: 401 bytes!Content-to-markup ratio: 0.03!
  46. 46. To summarize...!
  47. 47. JavaScript!WSH!HTTPWatch!Monitor!DOM and HTTP!IE and Firefox!
  48. 48. Thanks!!phpied.com!

×