Lỗi: Không sử dụng trình nghe bị động để cải thiện hiệu suất cuộn trong wordpress

Thảo luận trong 'Tin tức lập trình Website' bắt đầu bởi seolagi, 25/12/20.

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,029
    Đã được thích:
    81
    Điểm thành tích:
    48
    HI mọi người, em kiểm tra web em làm bằng wodpress themes flasome kiểm tra tốc độ tại developers.google.com/speed/pagespeed/insights/ thì bị báo lỗi

    Lỗi: Không sử dụng trình nghe bị động để cải thiện hiệu suất cuộn wordpress

    Lỗi này là gì vậy? bạn nào biết giúp mình với, tự nhiên bị lỗi này không hiểu là do cái gì cả. Cảm ơn
     
    Cảm ơn đã xem bài:

    Lỗi: Không sử dụng trình nghe bị động để cải thiện hiệu suất cuộn trong wordpress

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,905
    Đã được thích:
    1,199
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Bạn chèn code sau vào function.php của themes là vượt qua được lỗi đó nhé:
    PHP:
    function add_script_fix_devgg(){ ?>
        <script>
          (function() {
            var supportsPassive = eventListenerOptionsSupported();
            if (supportsPassive) {
              var addEvent = EventTarget.prototype.addEventListener;
              overwriteAddEvent(addEvent);
            }
            function overwriteAddEvent(superMethod) {
              var defaultOptions = {
                passive: true,
                capture: false
              };
              EventTarget.prototype.addEventListener = function(type, listener, options) {
                var usesListenerOptions = typeof options === 'object';
                var useCapture = usesListenerOptions ? options.capture : options;
                options = usesListenerOptions ? options : {};
                options.passive = options.passive !== undefined ? options.passive : defaultOptions.passive;
                options.capture = useCapture !== undefined ? useCapture : defaultOptions.capture;
                superMethod.call(this, type, listener, options);
              };
            }
            function eventListenerOptionsSupported() {
              var supported = false;
                try {
                var opts = Object.defineProperty({}, 'passive', {
                  get: function() {
                    supported = true;
                  }
                });
                window.addEventListener("test", null, opts);
              } catch (e) {}
              return supported;
            }
          })();
        </script>
      <?php 
    }
    add_action('wp_footer''add_script_fix_devgg');
     


Chủ để tương tự : Lỗi Không
Diễn đàn Tiêu đề Date
Tin tức lập trình Website 4 lợi ích của Hosting tốc độ cao không giới hạn băng thông 10/8/16
Tin tức lập trình Website Cảnh báo lỗi: Missing theme-color trong meta website 24/12/20
Tin tức lập trình Website Lỗi Part of this page are not secure such as images khi cài xong SSL 14/1/20
Tin tức lập trình Website Lợi ích của việc thiết kế website chuyên nghiệp cho doanh nghiệp? 6/8/19
Tin tức lập trình Website Lợi ích của việc Thiết kế website chuyên nghiệp 6/8/19