当前位置: 首页 > news >正文

网站营销案例长沙网站推广seo

网站营销案例,长沙网站推广seo,微信商城小程序平台,网站宣传推广的目的字玩FontPlayer开发笔记4 性能优化 首屏加载时间优化 字玩FontPlayer是笔者开源的一款字体设计工具,使用Vue3 ElementUI开发,源代码: github: https://github.com/HiToysMaker/fontplayer gitee: https://gitee.com/toysmaker/fontplayer …

字玩FontPlayer开发笔记4 性能优化 首屏加载时间优化

字玩FontPlayer是笔者开源的一款字体设计工具,使用Vue3 + ElementUI开发,源代码:
github: https://github.com/HiToysMaker/fontplayer
gitee: https://gitee.com/toysmaker/fontplayer

笔记

最近把本地开发已久的项目部署到阿里云上,但是由于笔者买的套餐带宽有限,加载速度非常慢,而SPA又将所有js打包到一个文件中,导致首屏白屏很久。但是提高带宽又比较贵目前还没有必要。无奈之下,我将项目在线体验部署到Github Pages上,暂时速度可以接受。但是首屏加载时间的优化(主要集中在打包js大小)还是个棘手的问题,需要好好研究。目前我采取的方法有:

1. FontAweSome按需加载

原来加载了全部FontAweSome图标:
(main.ts中代码)

import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { far } from '@fortawesome/free-regular-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'library.add(fas, far, fab)

现在替换成:
(main.ts中代码)

import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import {faArrowPointer,faCircle,faPercent,faArrowDownWideShort,faPenNib,faSquare,faDrawPolygon,faImage,faFont,faTerminal,faSliders,faTableCells,
} from '@fortawesome/free-solid-svg-icons'
import {faHand,faSquare as faSquare_regular,faCircle as faCircle_regular,
} from '@fortawesome/free-regular-svg-icons'
library.add(faArrowPointer,faCircle,faPercent,faArrowDownWideShort,faPenNib,faSquare,faDrawPolygon,faImage,faFont,faTerminal,faSliders,faTableCells,faHand,faSquare_regular,faCircle_regular,
)

2. Element Icon按需引入

原来加载了全部图标:
(main.ts中代码)

import * as ElementPlusIconsVue from '@element-plus/icons-vue'for (const [key, component] of Object.entries(ElementPlusIconsVue)) {app.component(key, component)
}

现在替换成:
(main.ts中代码)

import { Files, Edit, Upload, Download, Tickets, Setting, List, Tools } from '@element-plus/icons-vue'app.component('Files', Files)
app.component('Edit', Edit)
app.component('Upload', Upload)
app.component('Download', Download)
app.component('Tickets', Tickets)
app.component('Setting', Setting)
app.component('List', List)
app.component('Tools', Tools)

3. 将首屏不用的代码放到最后,防止阻塞页面

笔者项目中引入了opencv.js:

<script src="lib/opencv.js"></script>

opencv.js是个比较大的库,首屏也不需要用到,就放到了html最底端

4. 加载首屏loading动画

在首屏加载文件白屏时,加一个loading动画可以提升用户体验,注意loading动画的css最好放在html头部,而不能放在外部style.css中防止loading字样已经显示,而动画样式还没有加载。

在src/index.html中,添加以下代码:

<div class="empty" style="position: absolute;z-index: -99;top: 0;left: 0;right: 0;bottom: 0;display: flex;flex-direction: column;align-items: center;justify-content: center;
"><div class="enpty-tips">首次打开可能会有些慢,感谢耐心等待</div><div class="empty-loading" style="display: flex;flex-direction: row;gap: 20px;align-items: center;justify-content: center;margin-top: 48px;"><div class="loading-1" style="width: 14px;height: 14px;border-radius: 50%;background-color: black;"></div><div class="loading-2" style="width: 14px;height: 14px;border-radius: 50%;background-color: black;"></div><div class="loading-3" style="width: 14px;height: 14px;border-radius: 50%;background-color: black;"></div></div>
</div>
<style>body, html {width: 100%;height: 100%;position: relative;padding: 0;margin: 0;overflow: hidden;}.empty {.empty-loading {.loading-1 {animation: loading-1 2s;animation-iteration-count: infinite;}.loading-2 {animation: loading-2 2s;animation-iteration-count: infinite;}.loading-3 {animation: loading-3 2s;animation-iteration-count: infinite;}}}@keyframes loading-1 {0% {opacity: 1;}25% {opacity: 0.5;}50% {opacity: 1;}}@keyframes loading-2 {0% {opacity: 1;}50% {opacity: 0.5;}75% {opacity: 1;}}@keyframes loading-3 {0% {opacity: 1;}75% {opacity: 0.5;}100% {opacity: 1;}}
</style>

5. treeshaking

vite自动支持treeshaking,可以将程序中没有引用的模块清除掉,减小最终打包文件大小。

6. 可视化检查

可以使用rollup-plugin-visualizer库可视化查看各个模块大小,进行进一步排查处理。
在vite.config.ts中设置如下:

import { visualizer } from 'rollup-plugin-visualizer'export default defineConfig({plugins: [vue(),visualizer({open: true,})],//...
})

运行后会自动生成可视化分析图。

首屏加载时间性能优化是个需要深入研究的问题,笔者在这方面还非常初级,也非常渴望学习,解决项目中的问题,非常欢迎交流讨论!

http://www.tj-hxxt.cn/news/86179.html

相关文章:

  • 亚马逊网网站建设规划报告怎么建网站教程图解
  • 网站建设实习生怎么样公司网站制作教程
  • 博学云网站建设搜索指数的数据来源
  • 做富集分析的网站衡阳百度seo
  • 乡村建设相关网站北京建站优化
  • 武汉电子商务网站建设上海有名网站建站开发公司
  • 汕头多语种网站制作站长友情链接平台
  • 龙岩市住房和城乡建设厅网站成都网站seo费用
  • 做网站怎么写代码陕西新站seo
  • 微信公众平台微网站怎么做天津seo培训机构
  • tp5.1做的网站网址推广
  • 徐州 网站建设搜索引擎营销的方法有哪些
  • 微信商城下载手机系统优化
  • 附近广告公司喷绘刻字优化seo是什么
  • 成都高端网站建设公司seo按照搜索引擎的什么对网站
  • ssh框架做的家政服务网站网页设计与制作考试试题及答案
  • 企业+php网站建设app推广方法
  • 园林景观效果图网站武汉seo引擎优化
  • 网站模板下载大全商城网站建设
  • 手机网站怎么备案搜索引擎优化推广
  • 商城微网站如何做企业宣传视频
  • 建设基础化学网站的经验搭建网站平台
  • 珠海手机网站建设推广公司seo搜索引擎实训心得体会
  • 做rom的网站沧州seo公司
  • 昆明疫情最新消息今天上海网络营销seo
  • 做网站公司的未来企业文化
  • 网络软文推广网站百度seo排名优化助手
  • 浙江人工智能建站系统软件软文营销ppt
  • 网站开发团队组成seo发展前景怎么样啊
  • 手机网站模板 html5推广赚钱一个2元