Refactoring Javascript with Fred Lawler (Design + Code Series Appendix)




Refactoring Javascript is a common task for the developer. Today I invite Fred Lawler to give us some pointer.

Fred’s branch – https://github.com/fredlawl/Design-Code/blob/review/assets/js/functions.js

Fred on Twitter: https://twitter.com/LTSuperbus
Fred on Github: https://github.com/fredlawl

– – –

This video was sponsored by the DevTips Patron Community – https://www.patreon.com/DevTips

Listen to Travis’ Podcast – http://www.travandlos.com/

Get awesomeness emailed to you every thursday – http://travisneilson.com/notes

You should follow DevTips on Twitter – https://twitter.com/DevTipsShow

Original source


20 responses to “Refactoring Javascript with Fred Lawler (Design + Code Series Appendix)”

  1. Is that considered to be functional programming in javascript that Fred was doing here? I mean all these modularity things. Because I was watching learncode.academy videos on modular javascript from OOP side and he modularizes the code into objects, whereas Fred just put everything into function scope. What is the difference?

  2. This was great! I've been learning js using the book 'javascript & jquery' by jon duckett lately, and it has definitely helped me understand most of what Fred said and did throughout this video! Can't wait to see new js videos @devtips!

  3. Easy way to refactor JQuery, start by eliminating sizzle and make some accessor modules that cache the DOM via javascript. Why is it important? Recursive lookups take time. For example:

    $('.mobile-nav-toggle') inside the mobile nav function

    That basically means every time that function is called, javascript first has to do a recursive lookup on the DOM to find the element it needs to effect. One of these actions might be OK but what if you have 2 or 3 happening simultaneously? That's 2-3 recurive lookups.

    Instead there are ways of caching the DOM within javascript so that you can just invoke a state change.

Leave a Reply