-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Readme.md simplified Chinese version finished #36
Comments
Thanks for contributing such brilliant tool. We've translated the 一句话介绍 quicklink
工作原理Quicklink 通过以下方式加快后续页面的加载速度:
开发原因该项目旨在为网站提供一套解决方案,预获取处于用户视区中的链接,同时保持极小的体积(minified/gzipped 后 <1KB)。 安装方法node 或 npm 用户: npm install --save quicklink 或者从 unpkg.com/quicklink 获取。 用法初始化后,quicklink 将在闲时自动预获取处于视区内的链接 URL。 快速上手: <!-- Include quicklink from dist -->
<script src="dist/quicklink.js"></script>
<!-- Initialize (you can do this whenever you want) -->
<script>
quicklink();
</script> 举个例子 🌰,你可以在 load 方法触发之后进行初始化: <script>
window.addEventListener('load', () =>{
quicklink();
});
</script> 或者导入 ES 模块: import quicklink from "dist/quicklink.mjs";
quicklink(); 以上配置适用于多页网站。 单页应用可以搭配 router 使用 quicklink:
APIquicklink 接受带有以下参数的 option 对象(可选):
待探索:
Polyfills
<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script> 或者,请参见 Intersection Observer polyfill。 示例为预获取操作自定义超时时间 默认超时时间为 2 秒(通过 requestIdleCallback),这里我们重写为 4 秒: quicklink({
timeout: 4000
}); 设置用于检测链接的 DOM 元素 默认值为 document。 const elem = document.getElementById('carousel');
quicklink({
el: elem
}); 自定义预获取 URL 数组 如果你想指定用于预获取的静态 URL 列表,而不是视区内的,你可以使用自定义 URL。 quicklink({
urls: ['2.html','3.html', '4.js']
}); 为预获取操作设置请求优先级 默认为低优先级(rel=prefetch 或 XHR)。 对于高优先级(priority: true)的操作,尝试使用 fetch() 或退阶使用 XHR。 quicklink({ priority: true }); 浏览器支持quicklink 提供的预获取是渐进增强的(progressive enhancement), 跨浏览器支持如下:
某些功能支持分层实现:
直接使用 prefetcher(预获取器)quicklink 包含一个预获取器,可以单独导入其他项目中。 将 quicklink 作为依赖项安装后,可以按如下方式使用它: <script type="module">
import prefetch from '../src/prefetch.mjs';
const urls = ['1.html', '2.html'];
const promises = urls.map(url => prefetch(url));
Promise.all(promises);
</script> Demo这个 WebPageTest demo 演示了 quicklink 的预获取功能,它将页面加载性能提高了 4 秒! Youtube 视频 见此处。 请注意:这绝不是对这项技术优缺点的详尽测试,只是演示了该方法可能带来的潜在改进。 你自己的实现可能不尽相同。 相关项目
证书受 Apache-2.0 开源许可证保护。 You can find it here also. |
Thanks for the translation! @KyleAMathews I see for Gatsby you settled on a translations directory that looks a little like https://github.com/gatsbyjs/gatsby/tree/master/translations/es. Would you say this is a fair approach to things like README translations? |
Oh... that was just a one off thing — we haven't settled on a pattern yet per se as we're not supporting translations. That being said, a translations directory sounds great for a smaller library like this which will probably only ever have one README. |
Thanks for the input on how you're using that directory, @KyleAMathews! @jothy1023, did you want to PR in this translation into /translations/zh-cn/README.md? Or was more an fyi about the translated docs? 😄 |
Absolutely! I would love to PR. 😄 |
docs(README): add simplified Chinese version for README.md (#36)
This has now landed in master. Thank you! |
😄Wow, glad to see that. Thank you for linking the MDN docs to their Chinese version - Icing on the cake🍰! |
good job姐姐仔 |
No description provided.
The text was updated successfully, but these errors were encountered: