Code xoá dns-prefetch s.w.org trong WordPress ~ Kiếm Tiền Online

Sunday, February 4, 2024

Code xoá dns-prefetch s.w.org trong WordPress

Trong WordPress, <link rel="dns-prefetch"> được tiêu dùng để cải thiện tốc độ tải trang web bằng cách nạp trước DNS giúp cải thiện DNS query

Code xoá dns-prefetch s.w.org trong WordPress

Khi trình duyệt thấy một thẻ <link rel="dns-prefetch">, nó sẽ khởi đầu quá trình thực hiện prefetch DNS, nghĩa là nó sẽ nạp thông tin DNS từ máy chủ mà trang web cần truy cập trước khi thực sự đề nghị tài nguyên đó. Điều này giúp giảm thiểu độ trễ khi trình duyệt cần tải các tài nguyên từ máy chủ được đặt sẵn DNS.

Nhưng trường hợp <link rel="dns-prefetch"> sẽ nạp trước DNS cho máy chủ chứa các tài nguyên của WordPress.com (s.w.org) nhưng hầu hết việc này không cần thiết vì rất ít file tĩnh lưu trữ từ s.w.org

Đây là code mặc định do WordPress tạo ra

<head>    <meta charset="UTF-8" />    <meta name="viewport" content="width=device-width, initial-scale=1" />    <link rel="profile" href="https://gmpg.org/xfn/11" />    <title>Clean wp-head</title>    <link rel='dns-prefetch' href='//s.w.org' />    <link rel="alternate" type="application/rss+xml" title="Clean wp-head » Feed" href="https://clean-wp-head.dev/feed" />    <link rel="alternate" type="application/rss+xml" title="Clean wp-head » Comments Feed" href="https://clean-wp-head.dev/comments/feed" />    <script type="text/javascript">black        window._wpemojiSettings = {"baseUrl":"https://s.w.org/images/core/emoji/12.0.0-1/72x72/","ext":".jpg","svgUrl":"https://s.w.org/images/core/emoji/12.0.0-1/svg/","svgExt":".svg","source":{"concatemoji":"https://clean-wp-head.dev/wp-includes/js/wp-emoji-release.min.js?ver=5.2"}};        !function(a,b,c){function d(a,b){var c=String.fromCharCode;l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,a),0,0);var d=k.toDataURL();l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,b),0,0);var e=k.toDataURL();return d===e}function e(a){var b;if(!l||!l.fillText)return!1;switch(l.textBaseline="top",l.font="600 32px Arial",a){case"flag":return!(b=d([55356,56826,55356,56819],[55356,56826,8203,55356,56819]))&&(b=d([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]),!b);case"emoji":return b=d([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340]),!b}return!1}function f(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var g,h,i,j,k=b.createElement("canvas"),l=k.getContext&&k.getContext("2d");for(j=Array("flag","emoji"),c.supports={everything:!0,everythingExceptFlag:!0},i=0;i<j.length;i++)c.supports[j[i]]=e(j[i]),c.supports.everything=c.supports.everything&&c.supports[j[i]],"flag"!==j[i]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[j[i]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(h=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",h,!1),a.addEventListener("load",h,!1)):(a.attachEvent("onload",h),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),g=c.source||{},g.concatemoji?f(g.concatemoji):g.wpemoji&&g.twemoji&&(f(g.twemoji),f(g.wpemoji)))}(window,document,window._wpemojiSettings);    </script>    <style type="text/css">        img.wp-smiley,        img.emoji {            display: inline !important;            border: none !important;            box-shadow: none !important;            height: 1em !important;            width: 1em !important;            margin: 0 .07em !important;            vertical-align: -0.1em !important;            background: none !important;            padding: 0 !important;        }    </style>    <link rel='stylesheet' id='wp-block-library-css'  href='https://clean-wp-head.dev/wp-includes/css/dist/block-library/style.min.css?ver=5.2' type='text/css' media='all' />    <link rel='stylesheet' id='wp-block-library-theme-css'  href='https://clean-wp-head.dev/wp-includes/css/dist/block-library/theme.min.css?ver=5.2' type='text/css' media='all' />    <link rel='stylesheet' id='twentynineteen-style-css'  href='https://clean-wp-head.dev/wp-content/themes/twentynineteen/style.css?ver=1.4' type='text/css' media='all' />    <link rel='stylesheet' id='twentynineteen-print-style-css'  href='https://clean-wp-head.dev/wp-content/themes/twentynineteen/print.css?ver=1.4' type='text/css' media='print' />    <link rel='https://api.w.org/' href='https://clean-wp-head.dev/wp-json/' />    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://clean-wp-head.dev/xmlrpc.php?rsd" />    <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://clean-wp-head.dev/wp-includes/wlwmanifest.xml" />    <meta name="generator" content="WordPress 5.2" /></head>

Ví dụ, nếu trang web của bạn tiêu dùng các biểu tượng xã hội từ máy chủ s.w.org, bạn có thể thêm thẻ <link rel="dns-prefetch"> vào mã HTML của trang web của bạn để giúp trình duyệt tải DNS cho máy chủ s.w.org trước khi cần tải biểu tượng cảm xúc. Điều này có thể giúp cải thiện tốc độ tải trang web và trải nghiệm người dùng tổng thể.

Tuy nhiên, việc tiêu dùng <link rel="dns-prefetch"> cần phải được thực hiện cẩn thận để đảm bảo rằng bạn chỉ đặt sẵn DNS cho các tài nguyên thực sự cần thiết và không gây ra tăng tải cho máy chủ DNS của bạn.

Nói ngắn gọn nếu bạn không thấy tài nguyên nào được lưu từ s.w.org thì nên xoá <link rel="dns-prefetch"> khởi header đi sẽ có lợi hơn.

Để xoá <link rel="dns-prefetch"> bạn có thể add code phía dưới vào file functions.php là xong.

add_filter( 'wp_resource_hints','vts_remove_dns_prefetch',20,2);function vts_remove_dns_prefetch( $urls, $relation_type ){	$n = 0;	$k = false;	foreach( $urls as $url ){		if( false !== strpos( $url,'s.w.org' ) ){			$k = $n;		}		++$n;	}	if( $k ){		unset( $urls[$k] );	}	return $urls;}

Hy vọng code nhỏ sẽ giúp ích cho nhiều người.

Related Posts:

  • Khắc phục lỗi chia sẻ bài viết lên Facebook, Zalo không hiện ảnhKhắc phục lỗi chia sẻ bài viết lên Facebook, Zalo không hiện ảnhNếu bạn là người mới làm website, hoặc quản trị website có thể bạn sẽ gặp trường hợp chia sẽ bài viết của mình lên các mạng xã hội như Facebook, Zalo, Twitter … … Read More
  • Code css làm đẹp trang báo lỗi 404 theme FlatsomeCode css làm đẹp trang báo lỗi 404 theme FlatsomeFlatsome là theme có nhiều chức năng giúp người dùng tạo website nhanh chóng và chuyên nghiệp, bạn có thể tìm hiểu và làm được website đẹp trong thời gian ngắn với Flatsome.Ngo… Read More
  • Nonce trong WordPress là gì?Nonce trong WordPress là gì?WordPress cung cấp một hệ thống nonce dễ tiêu dùng để tạo và xác minh các hàm băm cho các hành động nhất định. Nonce giúp bảo vệ khỏi một số loại tấn công như Cross Site Request Forgery (CSRF)Nonce… Read More
  • Tăng giới hạn tải lên thư viện ảnh WordPressTăng giới hạn tải lên thư viện ảnh WordPressMột số nhà cung cấp hosting họ không chăm lo phần tương trợ các cài đặt phần giới hạn tải lên thư viện WordPress nên nếu bạn upload 1 file ảnh hoặc 1 file PDF … nào đó có dung lượng… Read More
  • Xóa tùy chọn ngôn ngữ trong trang login WordPressXóa tùy chọn ngôn ngữ trong trang login WordPressTừ phiên bản WordPress 5.9 , khi vào trang đăng nhập website bạn sẽ có 1 dropdown menu để bạn chọn ngôn ngữ. Nếu như bạn không thích điều này và muốn website gọn gàng hơn thì b… Read More

0 nhận xét:

Post a Comment

Chăm sóc tóc

DUNG DỊCH TẮM GỘI KHÔ – PH
90.000₫
MẶT NẠ TÓC PHỤC HỒI HƯ TỔN PREMIUM REPAIR MASK 180G – TSUBAKI
225.000₫
BỒ KẾT HOA BƯỞI 300ML – NCT3
340.000₫
DẦU XẢ THẢO DƯỢC BỒ KẾT SẢ CHANH HOA BƯỞI 300ML – TRƯỜNG HƯNG THỊNH
100.000₫
DẦU GỘI THẢO DƯỢC BỒ KẾT SẢ CHANH HOA BƯỞI 300ML – TRƯỜNG HƯNG THỊNH
100.000₫
SERUM DƯỠNG TÓC HOA BƯỞI GIẢM GÃY RỤNG 50ML – POMELO
84.000₫

Quảng cáo

Nổi bật

Cài đặt Thanh Toán Google adsense bằng ngân hàng Vietcombank

Sau khi đã đủ điều kiện rút tiền từ Google Adsense thì bạn cần phải thêm hình thức thanh toán để Google trả tiền cho bạn.Khi kiếm tiền trên ...

a-ads

Máy tính Laptop

44.990.000đ
Laptop LG Gram 2022 17Z90Q-G.AH76A5 (Core-i7 1260P/16GB/512GB/17″ WQXGA/Win 11/Xám)
24.790.000đ
Laptop LG Gram 2021 16ZD90P-G.AX54A5 (i5-1135G7/8GB RAM/512GB SSD/16″WQXGA/Dos/Trắng)
14.590.000đ
Laptop Acer Gaming Aspire 7 A715-42G-R4ST NH.QAYSV.004 (R5 5500U/8GB RAM/256GB SSD/15.6″FHD IPS/GTX1650 4GB/Win10) – Hàng chính hãng
15.190.000đ
Laptop Acer Aspire 3 A315-58G-50S4 (Core i5 1135G7/8GB RAM/512GB/15.6″FHD/MX350 2GB/Win 10/Bạc)
21.990.000đ
Laptop Acer Swift 5 SF514-55TA-59N4 NX.A6SSV.001 (i5-1135G7/16GB RAM/1TB SSD/14″FHD_Touch/Win10/Xanh) – Hàng chính hãng
14.890.000đ
Laptop Acer Aspire 5 A514-54-59QK (Core i5 1135G7/8GB RAM/512GB/14″FHD/Win 11/Vàng)

Vay Online

(x)
(x)
Day noi mi | Hoc noi mi | Noi mi dep | Trung tam day nghe toc | Day cat toc | Day nghe toc | Hoc cat toc | Hoc cat toc o Ha Noi | Hoc cat toc tai Ha Noi | Thuoc chua benh a sung
Dau goi Kafen | Dau xa Kafen | Giao trinh day cat toc | Mua ban rao vat | Dang rao vat | Dien dan rao vat | Rao vat mien phi | Trang rao vat

Mua Hang Gia Re / Cho Dien Tu / Mua Hang Online Uy Tin / Sim So Dep / Mua Hang Online / Dung Cu Cat / Dung Cu Cat Gia Re / Ban Buon Dung Cu Cat / Hoc Cat Toc / Dang Rao Vat / Dien dan Rao Vat / Trang Rao Vat / Day Noi Mi / Rao Vat Cho Tot / Quang Cao Rao Vat / Camera Quan Sat / Cac Website Rao Vat / My Pham Nganh Toc / Phu Kien Nganh Toc / Phuong Phap Tap Gym / Kiem Tien Tren Mang / Trung Tam Day Nghe Toc / VPS Gia Sieu Re / VPS Gia Sieu 10K / Thiet Ke Web Gia Re / Bat Dong San