turbolinksとは
TurbolinksはRails4.0からデフォルトで導入されたgem
ajaxとhistoryAPI(popState, pushState)を利用して画面遷移
js, cssの読み込みを初回時に行い次回以降の読み込み処理を省略することで高速化する。
主なTurbolinksの動作は2つ
fetchReplacement
<a>
タグのリンクをクリックした時の遷移をajax化して画面遷移なしにページ遷移する。clickイベントの挙動を変えている
fetchHistory
戻るボタンなどを押した時のイベントを書き換えている
fetchReplacement時にpushStateでキャッシュしたページをpopStateで復元する。