• Email
  • Like
  • Save
  • Private Content
  • Embed
 

5 Tips for Better JavaScript

by on Aug 29, 2012

  • 57,240 views

Love it or hate it, JavaScript is playing an increasingly important role in the next generation of web and mobile apps. As code continues to move from the server to the client, JavaScript is being ...

Love it or hate it, JavaScript is playing an increasingly important role in the next generation of web and mobile apps. As code continues to move from the server to the client, JavaScript is being used to do more than simple HTML manipulation. Be prepared for this transition and make sure the JavaScript you write is optimized and ready to perform on desktops and devices! In this session, you will learn ten practical tips that you can use today to write faster, more maintainable, memory friendly JavaScript.

Accessibility

Categories

Upload Details

Uploaded via SlideShare as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel

31 Embeds 1,624

http://www.cs.uoregon.edu 982
https://twitter.com 128
http://cit-web-dev.blogspot.com 124
http://clusterexample.tf.etondigital.com 110
http://www.scoop.it 54
http://blogdefegb.blogspot.com 54
http://localhost 42
http://www.mobileigniter.com 24
http://nicolechung.github.com 19
http://muziekstudioapeldoorn.nl 16
https://si0.twimg.com 15
http://www.ayhankuru.com 12
http://emcblog.nl 9
http://twitter.com 5
http://class2go.auca.kg 5
http://blogdefegb.blogspot.com.es 3
http://mobileigniter.com 2
http://beta.jolicloud.co 2
http://jolidev10-jolicloud.dotcloud.com 2
http://trunk.devenvbkgrl 2
https://twimg0-a.akamaihd.net 2
https://it.twitter.com 2
http://pinterest.com 2
http://www.twylah.com 1
http://nicolechung.github.io 1
http://www.linkedin.com 1
http://www.zendistro.com 1
http://cit-web-dev.blogspot.ru 1
http://www.acumensofttech.com 1
http://b.hatena.ne.jp 1
http://bottlenose.com 1

More...

Statistics

Likes
81
Downloads
287
Comments
10
Embed Views
1,624
Views on SlideShare
55,616
Total Views
57,240

110 of 10 previous next Post a comment

  • simevidas Šime Vidas, JavaScript programmer @toddanglin1 No problem. I enjoyed writing the comment :) 8 months ago
    Are you sure you want to
  • toddanglin1 Todd Anglin, VP Html5 Web & Mobile Tools at Telerik @Šime- First, I'm glad you spent a long time studying these slides! Your feedback is probably better for a blog than a comment, but I will say that some of the things you highlight are discussed in the actual 'live' session (what these slides were developed for). There are in fact intentional errors in the code that get discussed in the context of JSLint. :) Either way, thanks for reviewing the deck and for taking time to share feedback. 8 months ago
    Are you sure you want to
  • simevidas Šime Vidas, JavaScript programmer ★★★ SLIDE 26 ★★★ The 'best' solution can be further improved. Instead of invoking the css() method two times in a row (to set two CSS properties), you can just invoke it once and pass an object literal: $myDiv.css({ color: 'red', opacity: 1 }); ★★★ SLIDE 27 ★★★ I don't agree with this slide. The Array iteration methods should be used instead of the for loop when possible. They perform slightly worse (as expected), but they are higher-level, which makes the code more readable. So, .forEach() is a better solution than the for loop. ★★★ SLIDE 28 ★★★ 'They're slow and rude.' No, you're missing the point. Performance is not the reason why the use of global variables should be minimized. The actual reason are name collisions. The global namespace in browsers contains hundreds of built-in names (e.g. window, top, location, setTimeout). If a JavaScript program creates additional global variables, that can lead to name collisions, which can cause either the program or the browser's built-in API to behave unexpectedly. ★★★ SLIDE 30 ★★★ If those examples are global code, than neither example is good (since the use of global functions should be minimized). If those examples are not global code, then which solution is better really depends on what the scope of the 'name' variable should be. If only one function needs this value, it can be declared as a local variable. However, if multiple functions need access to that value, then it makes sense to declare it in an outer scope. So, the 'BAD' example doesn't have to be bad at all. It just depends on the context. ★★★ SLIDE 36 ★★★ Delegating all the way back to the document? Why? It should be enough to delegate to the root element of the web-app or module. Those last few jumps (... -> body -> html -> document) don't provide additional value (at least not for a button click). ★★★ TYPOS ★★★ Slide 33 - a right paren is missing on the last line. Slides 38, 39, 43-45 - the function is missing its header parens Also, you are missing semi-colons on a bunch of lines. ASI takes care of that, but your code is inconsistent. 8 months ago
    Are you sure you want to
  • toddanglin Todd Anglin, VP HTML5 Web & Mobile Tools at Telerik @dsfernandes Unfortunately, no. At least, not yet. First iteration was not recorded, but I'll definitely be presenting it again in the future. I'll try to get one of the conference recordings on YouTube. Or maybe I should just do a webcast for all? 8 months ago
    Are you sure you want to
  • dsfernandes dsfernandes Is the actual talk available somewhere? I really liked the slides, but it would be best if I could also listen to the speaker :) 8 months ago
    Are you sure you want to
  • anilbms Anil Kumar Krishnashetty, Front End Web Developer at SAP @David: Accessing DOM every time is expensive , that's why we prefer to cache. 8 months ago
    Are you sure you want to
  • toddanglin Todd Anglin, VP HTML5 Web & Mobile Tools at Telerik @Tamás- True, I do use a lot of jQuery for the examples, primarily because it's the most popular JavaScript library. You'll also note, though, that part of the presentation calls-out some of the performance weaknesses associated with jQuery. In general, though, the tips do not depend on jQuery (and in some cases actually recommend away from jQuery). Hope that helps. 8 months ago
    Are you sure you want to
  • tamaskovari3 Tamás Kővári, Senior Programozó at Docler you're talking about javascript, but only jQuery I can see. 8 months ago
    Are you sure you want to
  • toddanglin1 Todd Anglin, VP Html5 Web & Mobile Tools at Telerik @David- In this case, 'best' is marked as such because in 'real world code' it's often better to just cache your selector up-front to avoid the temptation to do multiple DOM queries. Perf wise, they should be very similar. 8 months ago
    Are you sure you want to
  • davidcorbacho davidcorbacho Great slides Todd! In the slide 26, I don't see any difference respect 'Better' and 'Best' Blue and Violet colors in the chart: http://jsperf.com/caching-jquery-objects-perf 8 months ago
    Are you sure you want to
Post Comment
Edit your comment

5 Tips for Better JavaScript 5 Tips for Better JavaScript Presentation Transcript