We'll be back soon! Our site is currently undergoing maintenance. Please check back later.
Nicholad Zakas, who wrote this book, recently spoke about JavaScript performance at Google; his presentation was called “Speed Up Your JavaScript” and it’s available to view on Youtube. In the presentation Nicholas covers areas rarely talked about; he takes a low-level approach by explaining what’s happening behind the scenes when you do something as simple as creating or requesting a variable in
Google Tech Talk June 4, 2009 ABSTRACT Web Exponents: Speed Up Your JavaScript Presented by Nicholas C. Zakas. As an interpreted language, JavaScript is filled with hidden performance issues that conspire to slow down your code and ruin the user experience. Learn exactly what is fast, what is slow, and what you can do to squeeze that last bit of performance out of your JavaScript cod
JavaScriptActionScript/Flex ネタが続いているので、たまには JavaScript ネタを。はてブ経由で知った 最小完全ハッシュ関数の作り方 が面白そうだったのだけど、「最小完全ハッシュ関数」が何か分からないまま読み進めたら、やっぱり話が分からなくなってしまった。分からないまま JavaScript に移植。 /* 順列型の最小完全ハッシュ関数 */ function ChangeNumber(arr) { var work = arr.concat(); var hash = 0; // 階乗値テーブル作成 var FACTOR = [1]; for(var i=0; i { FACTOR.unshift(FACTOR[0] * (i+1)); } for(var i=0; i { hash += work[i] * FACTOR[i]; for (j=i+1;
JavaScript, event関西で JavaScript 勉強会を、ということで企画された Kanasan.JS に参加してきました。細かなレポートは各所に上がってるので、今更まとめる必要はなさそうです。技術的なアレコレに関しては、以下の3つのエントリがよくできてます。Greenbear Diary - Kanasan.JS (別名:prototype.jsのソースにツッコミを入れるオフ) に参加してきましたちょっとKanasan.JSまでいってきました - はこべにっき#Kanasan.JS レポート: Days on the Moonその他のレポートは、主催者のエントリ「Kanasan.JS無事終了しました (Kanasansoft Web Lab.)」のトラックバックから辿れるので、そちらを参考に。K-conbinatorPrototype.K 関数についてだけ補足しておこう。
JavaScriptjQuery を使って JSONP でリクエストする方法を2通り紹介するよ。その1: $("")createElement を $() を使って実装。 $("") .attr('type', 'text/javascript') .attr('src', "http://www.example.com/jsonp.cgi?param1=value1&callback=myCallback") .appendTo($("head")); function myCallback(json){ // ロード完了時にここが呼ばれる } http://www.example.com/jsonp.cgi?param1=value1&callback=myCallback にリクエストがいく。callback のところは、サービスによって指定の仕方が違うかもね。その2: $.ajax
JavaScriptJavaScript のイベントハンドラについて段階を追って説明した素晴らしい資料、「JavaScript のイベントハンドラ - daily dayflower」に次のような記述があった。JavaScript で関数を定義するのには,下記の3通りの手法があります。「function 文」による「関数定義」 「function 演算子」による「関数式」 Function() コンストラクタFunction() コンストラクタについては今回は触れていません。XXX() は「関数定義」,YYY は「関数式」になります。「関数定義」の場合,前述のように関数定義(実装)が前方参照可能になるという大きな違いがあります。 JavaScript のイベントハンドラ - daily dayflower言い換えると、 window.onload = hoge; function hoge
JavaScript文字列置換のお話。通常、replace は1回しか置換してくれない。 >>> "aaaa".replace("a", "A") "Aaaa" 何度も置換させるには、正規表現を使うのが手っ取り早い。 >>> "aaaa".replace(/a/g, "A") "AAAA" 置換前の文字列を文字列で受け取ったときには、正規表現オブジェクトを作ればよい。RegExp コンストラクタの第二引数がフラグ。 function myReplaceGlobal(str, before, after){ var reg = new RegExp(before, "g"); return str.replace(reg, after); } myReplaceGlobal("aaaa", "a", "A"); // AAAA ただ、. が任意の文字にマッチしてしまったりと、弊害もある。 m
javascript, asjQuery のソースコードを見ていて面白いのがあった。 function add(a, b){ addImpl(b && a, b || a); } function addImpl(a, b){ // ... } 理解するためには、論理演算子を詳しく理解する必要がある。論理演算子詳細JavaScript(というか ECMAScript)の論理演算子は、評価結果が true/false で返される訳ではなく、結果が確定した時点で評価した値が返される。まずは、|| を試してみよう。 alert(2 || 0); // 2 alert(2 || 3); // 2 alert({} || null) // [object Object] alert(0 || 3); // 3 alert(0 || 0); // 0 alert(0 || undefined); //
JavaScriptjQuery は機能が豊富なので、しばらく使わないと忘れてしまう。ここでは、jQuery と配列の関係に絞って目的別に逆引きできるようにしておく。配列から jQuery オブジェクトを作成$ 関数に渡せばOK $([1,2,3]) NodeList のような配列っぽいものを渡しても解釈してくれる。 $(document.getElementsByTagName("div")) // $("div") と同じ ※内部的には setArray メソッドが呼ばれてるが、外から使うことは稀。jQuery を配列のように扱う要素数を取得するlength プロパティを使えばOK。 $("div").length // document.getElementsByTagName("div").length と同じ jQuery のメソッドを使って操作する限りは、適切に length
JavaScriptjQuery の extend メソッドは便利なんだが複雑で忘れてしまいがちなのでメモしておく。jQuery.extend の呼び出しパターンは次の4通り。$.extend([deep,] target, obj1, [obj2, [obj3, ...)$.extend([deep,] obj)$.fn.extend([deep,] obj)$(...).extend([deep,] obj)全てのパターンで第一引数に [deep,] がある。これはオプションの引数で true を指定するとディープコピーしてくれる。以下では分かりやすくするために deep オプションは省略した一覧を掲載する。$.extend(target, obj1, [obj2, ...)$.extend(obj)$.fn.extend(obj)$(...).extend(obj)だいぶシンプルにな
Anyone who has done some web development over the last decade and a half has definitely heard about jQuery. This library did excellent work when it came to taking care of browser inconsistencies. You also had to write significantly less code compared to pure JavaScript in order to get something done. The large ecosystem of plugins around jQuery was also very helpful. The regular improvements in we
Thanks to everyone that attended the jQuery London and London Web Standards meetups this month. As requested, here are the slides from my talks including links to all of the jsPerf tests embedded for each section. Summary In case you missed the talk, the main takeaway from it was the importance of performance-testing your JavaScript and jQuery code (and appreciating performance gotchas you can kee
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く