今天对自己做的项目中的一个设计器界面加载速度上进行了优化,因为页面在加载的时候,感觉有点慢。首先,我用firefox的yslow和chrome的pagespeed进行了测试,效果如下,分数有点不同,但是都是很低的。我其实主要在chrome下用pagespeed的提示进行优化的。
yslow优化前:
yslow优化后:
pagespeed优化前:
pagespeed优化后:
优化策略:
1.tomcat配置启用gzip压缩
2.tomcat配置静态文件的过期时间
3.css放页面上方
4.javascript放页面下方
5.css和js文件分别合并、压缩
tomcat启用gzip压缩
打开tomcat的conf目录下的server.xml文件,修改如下
- Connector port="80" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" executor="tomcatThreadPool" URIEncoding="utf-8"
- compression="on"
- compressionMinSize="50" noCompressionUserAgents="gozilla, traviata"
- compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
参考链接:http://blog.csdn.net/hbcui1984/article/details/5666327
tomcat配置静态文件过期时间
打开tomcat的conf目录下的web.xml文件,增加如下:
- filter>
- filter-name>ExpiresFilterfilter-name>
- filter-class>org.apache.catalina.filters.ExpiresFilterfilter-class>
- init-param>
- param-name>ExpiresByType imageparam-name>
- param-value>access plus 10 minutesparam-value>
- init-param>
- init-param>
- param-name>ExpiresByType text/cssparam-name>
- param-value>access plus 10 minutesparam-value>
- init-param>
- init-param>
- param-name>ExpiresByType application/javascriptparam-name>
- param-value>access plus 10 minutesparam-value>
- init-param>
- filter>
- filter-mapping>
- filter-name>ExpiresFilterfilter-name>
- url-pattern>/*url-pattern>
- dispatcher>REQUESTdispatcher>
- filter-mapping>
过期时间:每次请求增加十分钟
参考链接:https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/filters/ExpiresFilter.html
css文件合并压缩,js文件合并压缩
合并压缩使用grunt进行处理,简单方便
参考链接:http://www.cnblogs.com/snandy/archive/2013/03/11/2949177.html
http://www.cnblogs.com/snandy/archive/2013/05/20/3088613.html
总体来说,页面加载速度有所提升,因页面设计器中,各个组件的js和核心js加起来有30多个,我只针对这方面进行了压缩合并,其他引入的js插件都是使用的压缩后的;css方面我也只压缩合并的我自己增加的文件。图片方面没有把所有图片都合并到一个文件中,只有少部分icon整合了,这方面合并后应该还会有所提升。

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!
