Skip to content

Instantly share code, notes, and snippets.

@japboy
Created February 10, 2013 09:03
Show Gist options
  • Save japboy/4748924 to your computer and use it in GitHub Desktop.
Save japboy/4748924 to your computer and use it in GitHub Desktop.
Frontrend Vol.4 メモ http://atnd.org/events/35720

Frontrend 04

JavaScript Development Tools

id:Layzie

GUI ツール

Chrome Develoepr Tools

Charles

DocHub

jsfiddle

jsperf

browserling

CUI ツール

JSHint

jq

  • jq
  • JSON processor
  • npm install -g jq
  • cat foo.json | jq '.results[]' | {from_user, test}

Doctor JS

Yeoman

Nodefront

jQuery Performance Tips

@pocotan001

速くするには、マシンの仕事を、少なくしろ。
  • パフォーマンスとメンテナンス性のトレードオフ
  • 2012-05 を境に JavaScript と jQuery の利用推移が逆転 (jQuery 増) した

ファイルサイズを減らす

  • 1ms / 1kb のパース時間 (モバイル)
  • MSIE の条件付コメントで読み込む jQuery を変更
  • Grunt のカスタムビルドで不要な機能を削除
  • ajax/css/effects/offset/dimensions の削除が可能 (最小構成から増やして行く)
  • jquery/jquery-migrate · GitHub
  • jquery-migrate.js による deprecated feature detection が提供されている

セレクタの高速化

// slow
$('#target p')
document.querySelectorAll('#target p')

// fast
$('#target').find('p')
document.getElementById('target') AND $.find('p')

リフローの影響を考える

視覚化

Chrome Developer Tools: Rendering -> Show piant rectangles

  • offsetposition は取得だけでもリフローが発生
// Reflowed
$('<p/>').append($body).hide()

// Non-Reflowed
$('<p/>').hide().append($body)

jQuery Animation vs. CSS3 Animation

throttle/debounce

まとめ

小さな効率は忘れよう。
時間の 97 % について語ろう。
はやまった最適化は諸悪の根源だ。

- Tony Hoare?

Testable JavaScript

@cssrader

テストしやすい JavaScript

テストしてますか

リファクタリングを前提で考える

The first draft of anything is shit

テストしづらい?

  • 文脈型のコードの色付して分類し、役割を見分ける
  • テストが難しいのであれば、テストしようとしているコードがテストしやすいコードになっていない
  • Adventures in JavaScript Development
  • テスト駆動開発
  • テスト駆動リファクタリングから
  • Steve Freeman

単一責任の原則

Write programs that do one thing and do it well.

studiomohawk/QOF · GitHub

ユニットテストのツール

Jasmine

Qunit

  • QUnit
  • Used by jQuery team
  • Easy to test DOM

Mocha

PhantomJS

Wiki

テストのセットアップ

テスト自動化

テストにふれる

まとめ

テストしやすい JavaScript を書く事

Why do we fall sir?
So we might learn to pick ourselves up

- Alfred Pennyworth

jQuery to Backbone

@ahomu

アーキテクチャを意識した JavaScript

  • Backbone: 構造化の手段を提供
  • Selector = jQuery
  • Utility = Underscore

Addy Osmani

MVC since 1979

Smalltalk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment