Home > CMS Tutorial > DEDECMS > body text

How does Dreamweaver improve the speed of web page access?

angryTom
Release: 2019-11-09 13:22:11
Original
1683 people have browsed it

How does Dreamweaver improve the speed of web page access?

How to improve the speed of web page access

We know that speeding up the opening speed of web pages is to improve the user experience an effective strategy. There are many factors that affect the opening speed of web pages. Today I will talk about how to speed up the opening speed of web pages by optimizing the internal program of DreamWeaver CMS.

First of all, process the Javascript of the article page. There is a large section of Javascript in front of the default template, which may be a little more than 2KB, and each page is 2KG. I will extract this JS and save it as a file. I only need to download it once in the future. But be careful to replace the path in JS according to your own situation.

Secondly, I found that the article was stuck when it came to the number of clicks. The time difference was less than ten seconds. I felt very bad. It turned out that I was checking data, which affected the speed. In fact, we can write it here using AJAX. The specific method is:

1. Modify the template to remove the line

<script src="{dede:field name=&#39;phpurl&#39;/}/count.php?view=yes&aid={dede:field name=&#39;id&#39;/}&mid={dede:field name=&#39;mid&#39;/}" type=&#39;text/javascript&#39; language="javascript"></script>
Copy after login

and add

2. Add a JS function to the JS file mentioned in the first step

function getClick(aid,mid) 
{ 
var taget_obj = document.getElementById(&#39;article_click&#39;); 
myajax = new DedeAjax(taget_obj,false,false,&#39;&#39;,&#39;&#39;,&#39;&#39;); 
myajax.SendGet2("/plus/count.php?ajax=yes&mid=" +mid +"&aid=" +aid); //这里要根据情况改成网站的实际路径 
DedeXHTTP = null; 
}
Copy after login

3. Modify the plus/count.php file. Add the following code before exit()

if(!empty($ajax)) 
{ 
$row = $dsql->GetOne(" Select click From `{$maintable}` where {$idtype}=&#39;$aid&#39; "); 
if(is_array($row)) 
{ 
echo $row[&#39;click&#39;]; 
} 
}
Copy after login

3. PutChanged to:

<script language="javascript" type="text/javascript">getClick({dede:field name=&#39;id&#39;/},mid={dede:field name=&#39;mid&#39;/});getDigg({dede:field.id/});</script>。
Copy after login

In fact, as long as the getClick function is placed at the end of the article, it doesn’t matter where it is.

Recommended tutorial: dedecms tutorial

The above is the detailed content of How does Dreamweaver improve the speed of web page access?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template