Home  >  Article  >  Web Front-end  >  网页加载速度优化2先加载css,然后再加载js文件。_html/css_WEB-ITnose

网页加载速度优化2先加载css,然后再加载js文件。_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:19:391131browse

网页加载时,是按从上到下,从左到右的顺序加载的。所以一定要先加载css文件(不要让用户看到一个杂乱无章的页面),最后再加载js文件,<br />js一般都是处理功能的,所以不需要提前加载。先给用户观感,再给用户上手体验。<br /><br /><!DOCTYPE html><br /><html lang="en"><br /><head><br />    <meta charset="UTF-8"><br />    <title>Title</title><br />    <!--先加载css --><br />    <link rel="stylesheet" href="style.css"><br /></head><br /><body><br /><!--然后加载网页内容 --><br /><h1>this is a demo html </h1><br /><br /><!--最后加载js文件--><br /><script src="index.js"></script><br /></body><br /></html>

Statement:
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