Comments (10)
一起讨论一下吧,tmallfe/tmallfe.github.io#34
你说的这种,一般都会combo的,把需要的模块的css和js分别打包成一个css和一个js,然后加载就行了。
from blog.
开发代码和部署代码中间经过了构建过程的,所以最终上线以后,资源会被合并请求,并不影响性能,甚至可以根据模块化的依赖关系更好的管理资源加载,做到非常精确的按需,性能更高
from blog.
我这边为自己封装实现了一个这样的插件(暂时还不能通用,没写好readme)
核心还是 资源依赖表。
在页面编译之后
- 会把该页面的所有 同步依赖模块(js、css) 合并成一个 combo url链接,然后replace到页面上。
- 会把该页面的所有 异步依赖模块 输出一份配置表,用来给浏览器进行加载,该配置表包含了 异步模块 的所有依赖,并且剔除了已经合并过的同步依赖模块。
- 可以配置combo url 的合并顺序,支持分组combo。
代码参考 (暂时未整理):https://github.com/jincdream/fis3-postpackager-autocombo/blob/master/index.js
from blog.
构建工具 + 根据业务情况合理使用合并请求解决请求数的问题
假设 fis + webpack 或者 gulp + webpack
- css 可以选择嵌入到 js ,或者所有依赖模块的 css 都用less打包在
view/login/index.less
页面只引入/view/index/index.less
。甚至将css 嵌入到 html - js 文件用 webpack 打包即可。这方面的优化要看 webpack 的 externals
- 图片资源必要时可以嵌入 css ,尽量用 iconfont
就近维护大法好,就近维护老板再也不用担心时间都浪费在找文件上。
from blog.
@nimojs
fis 自身就可以很优雅的解决这个问题,不用也没必要和 webpack 搭配使用
from blog.
@ystarlongzi JS异步加载JS是个问题 fis 纯前端的打包方案并不理想。
from blog.
@nimojs
fis 支持异步加载 js 的啊,我一直都是这么用的,之前使用 requirejs,现在使用的是百度的 modJs。
fis3-postpackager-loader
from blog.
@ystarlongzi modjs 全部是异步加载,而有时候我们需要文件模块直接被打包在一个文件。当需要异步的时候再用 require.ensure
异步加载。所以需要 webpack 来处理所有JS相关的代码
from blog.
@nimojs 嗯嗯。不过现在 modJS 里也有require.ensure
语法了.mod.js#L219-L223
from blog.
类似TAB这样既有交互性又有容器性质的组件,应该如何开发和使用呢?
在不使用react.js的情况下。按照在 #10 上组件化开发的**。
from blog.
Related Issues (15)
- 浅谈前端集成解决方案 HOT 102
- 前端工程——基础篇 HOT 601
- 前端开发体系建设日记 HOT 189
- 能列举个前端工程师技能套装吗 HOT 10
- 前端工程与性能优化 HOT 81
- 前端工程与模块化框架 HOT 95
- 模块化打包的大潮中,如何处理静态页面? HOT 10
- 一个程序员的成长之路 HOT 70
- 先部署页面再部署资源,不是会导致找不到资源吗? HOT 1
- 私人博客,请勿私自发起 Issue HOT 11
- 资源定位中md5戳的计算过程 HOT 86
- 大公司里怎样开发和部署前端代码? HOT 179
- 如何进行前端自动化测试? HOT 20
- 欢迎一起探讨各自在前端开发中遇到的工程问题 HOT 204
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.