From 22ca31bbb52632b42ab8d7ec61114355e59546a7 Mon Sep 17 00:00:00 2001 From: yafeilee Date: Sun, 7 Aug 2016 12:03:58 +0800 Subject: [PATCH] Add defer instead of async --- app/assets/javascripts/application.js | 4 +++- app/views/layouts/application.html.slim | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e43006a..9217973 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -8,4 +8,6 @@ //= require cable //= require_tree . -$(document).foundation(); +$(document).on('turbolinks:load', function(){ + $(document).foundation(); +}); diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 42220af..de07388 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -8,7 +8,7 @@ html = content_for?(:title) ? yield(:title) + " | #{ENV['SITE_NAME']}" : ENV['SITE_NAME'] = stylesheet_link_tag "application", 'data-turbolinks-track' => "reload" = favicon_link_tag 'favicon.png', type: 'image/png' - = javascript_include_tag "application", 'data-turbolinks-track' => "reload", 'async' => Rails.env.production? + = javascript_include_tag "application", 'data-turbolinks-track' => "reload", 'defer' => true = csrf_meta_tags = action_cable_meta_tag body data-whatinput="mouse"