Rapid Web Development Tips and tricks for Front End Development - - PowerPoint PPT Presentation

rapid web development
SMART_READER_LITE
LIVE PREVIEW

Rapid Web Development Tips and tricks for Front End Development - - PowerPoint PPT Presentation

Rapid Web Development Tips and tricks for Front End Development Javascript versions - ECMA 3 [Most successful yet] - ECMA 4 [Most unsuccessful] - ECMA 5 [Latest approved and live version] - ECMA 6 [Under development] Javascript cool parts


slide-1
SLIDE 1

Rapid Web Development

Tips and tricks for Front End Development

slide-2
SLIDE 2

Javascript versions

  • ECMA 3 [Most successful yet]
  • ECMA 4 [Most unsuccessful]
  • ECMA 5 [Latest approved and live version]
  • ECMA 6 [Under development]
slide-3
SLIDE 3

Javascript cool parts

slide-4
SLIDE 4

what is prototype and __proto__

  • Its native (not related to any library)
  • Usage

+ Lightweight instances + Used for inheritance

slide-5
SLIDE 5

How does it work

slide-6
SLIDE 6

hoisting

  • All variable declared anywhere in the current

scope always reach at the top

slide-7
SLIDE 7

how does it work ?

slide-8
SLIDE 8

Performance Optimization

slide-9
SLIDE 9

Closures

slide-10
SLIDE 10

why do closures leak?

  • Activation object is the state when a function is being

created.

  • Calling a function means pushing execution context on

top of activation object

  • In case of closures, leak happens because execution

context remains alive in the form of activation object of closure function.

  • Solution
  • define closure function seperately
  • copy the variables you need from parent.
slide-11
SLIDE 11

Visualize the leak

slide-12
SLIDE 12

DOM Access is costly

slide-13
SLIDE 13

Reduce DOM Access

slide-14
SLIDE 14

Do it offline - and then push it

  • use document.create()
  • use element.cloneNode()
  • use document.createDocumentFragment()
slide-15
SLIDE 15

Don't use window.setInterval

  • use requestAnimationFrame
  • a performance optimization tip
  • Pauses the timer when the page is inactive
slide-16
SLIDE 16

Reflow and Repaint

slide-17
SLIDE 17

Reflow and Repaint

  • DOM Tree and Render tree are maintained for every

HTML document

  • Layout changes cause reflow + repaint
  • Color changes cause only repaints
slide-18
SLIDE 18

Reflow and Repaint

  • How to minimize cost
  • setAttribute("style", "....")
  • use className
  • hide it
  • position absolute
  • copy -> change -> replace node
slide-19
SLIDE 19

Cool Development Tools

slide-20
SLIDE 20
  • Drag and drop in Elements panel
  • Undo (Ctrl+z) and Redo (Ctrl+Shift+z) in elements panel
  • Open files list (Ctrl + o)
  • Open member (Ctrl + Shift + o)
  • Recently touched nodes ($0 - $4)
  • Conditional breakpoints
  • View pseudo classes and add new
  • Multiline console (Press shift)
  • Prettify the scripts
  • Pause on error/exception
  • Dock to right
  • Console in any panel
  • Search in all scripts
  • Preserve log on navigation

Chrome Dev Tools (Tips)

slide-21
SLIDE 21

Sublime Text - 2

  • Bird eye view
  • Easy package installer
  • Really fast
  • Web Dev plugins (ZEN coding, etc.)
  • Accepts textmate plugins
  • Accepts custom build process
  • Supports VIM!
slide-22
SLIDE 22

Use ZEN coding

slide-23
SLIDE 23

Write test cases

  • Really good code practice
  • Slows down development in short term but you won't regret

writing it later

  • Avoids bugs
  • Prevents kids from changing your code's behaviour
  • Your are more confident about your code
  • Yeah, makes you better than others :-)
slide-24
SLIDE 24

Cooler stuff in JS

slide-25
SLIDE 25
  • querySelector, querySelectorAll
  • classList
  • matchesSelector
  • Element.focus()
  • outerHTML
  • insertAdjacentHTML
  • scrollIntoView
  • contains()

New DOM API

slide-26
SLIDE 26

Questions?

Amit Agarwal Web Developer, Google http://www.amitagrwal.com