Moritz Schmidt 9 年之前
父節點
當前提交
553bd2b84b
共有 2 個文件被更改,包括 16 次插入9 次删除
  1. 8 8
      dist/scripts.js
  2. 8 1
      functions.php

+ 8 - 8
dist/scripts.js

@@ -7,6 +7,14 @@ jQuery( document ).ready(function($) {
     $('.navbar-toggler').click();
   });
 
+  $(document).on('click', 'a.scroll-link[href^="#"]', function(e){
+    e.preventDefault();
+
+    $('html, body').animate({
+      scrollTop: $( $.attr(this, 'href') ).offset().top
+    }, 500);
+  });
+
   /** TdA Carousel **/
 
   $('.owl-carousel').slick({
@@ -21,12 +29,4 @@ jQuery( document ).ready(function($) {
       prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
   });
 
-  $(document).on('click', 'a.scroll-link[href^="#"]', function(e){
-    e.preventDefault();
-
-    $('html, body').animate({
-      scrollTop: $( $.attr(this, 'href') ).offset().top
-    }, 500);
-  });
-
 });

+ 8 - 1
functions.php

@@ -759,7 +759,14 @@ add_filter( 'wp_title', 'ams_modify_titles', 10, 2 );
 
 
 function my_async_scripts( $tag, $handle, $src ) {
-  return '<script type="text/javascript" src="' . $src . '" async></script>' . "\n";
+  // if($handle == "scripts") { // load scripts when everything else finished loading
+  //   return '<script type="text/javascript" src="' . $src . '" defer></script>' . "\n";
+  // }
+
+  if($handle != "jquery") { // only load jquery instant
+    return '<script type="text/javascript" src="' . $src . '" async></script>' . "\n";
+  }
+  return $tag;
 }
 add_filter( 'script_loader_tag', 'my_async_scripts', 10, 3 );