Import code from jquery.turbolinks 

Discussion: https://github.com/rails/turbolinks/issues/78