發現很多網站在放置百度分享代碼的時候,簡單的將分享代碼放置到固定的網頁位置就完事了,這是非常致命的方式。因為,我經常打開一個網頁的時候,發現在網頁加載到分享代碼的時候,有時候花上幾秒的時候來請求百度的服務器,最后展示分享按鈕。
其實,像這樣對網頁來說不是非常重要的功能,我們大可以用JS來延遲加載,從而提高網頁主要內容的快速加載顯示。
這里分享下我的放置方式。
一、copy百度分享代碼,如下:
復制代碼 代碼如下:
<!-- Baidu Button BEGIN -->
<div>
<a></a>
<a></a>
<a></a>
<a></a>
<a></a>
<span></span>
<a></a>
</div>
<script type="text/javascript" data="type=tools&uid=0" ></script>
<script type="text/javascript"></script>
<script type="text/javascript">
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>JS延遲加載百度分享代碼,提高網頁速度</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<style type="text/css">
body{margin:0px;padding:0px;font-size:12px;}
#copyright{clear:both;}
</style>
</head>
<body>
<div>
<!-- Baidu Button BEGIN -->
<div>
<a></a>
<a></a>
<a></a>
<a></a>
<a></a>
<span></span>
<a></a>
</div>
<script type="text/javascript" data="type=tools&uid=0" ></script>
<script type="text/javascript"></script>
<!-- Baidu Button END -->
</div>
<div>
<a >編程圖書PDF下載【codejia.net】</a>
</div>
<script type="text/javascript">
window.onload = shareCode;
function shareCode(){
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000);
}
</script>
</body>
</html>
新聞熱點
疑難解答
圖片精選