技术控

    今日:161| 主题:49347
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Lazy-loading ES2015 modules in the browser

[复制链接]
下一秒落寞 发表于 2016-10-1 11:29:42
143 1

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Over the last few years, developers have been relentlessly moving their server-side sites to the client-side on the premise that the page performance would be improved.
    However, this may not be enough. Have you ever considered that your site may be downloading more stuff than is being actually used? Meet Lazy-loading , a design pattern about deferring the initialization (loading/fetching/allocation) of a resource (code/data/asset) until the point at which it is needed.
    At the same time, ES2015 is already production-ready through transpilers such as Babel . Now you no longer need to fight the AMD vs CommonJS war - described on my article The mind-boggling universe of JavaScript Module strategies - since you can simply write ES2015 modules and have them transpiled and delivered to the browser, while supporting your existing CommonJS or AMD modules.
    This article demonstrates how to load ES2015 modules synchronously (during the page load) and asynchronously (performing lazy-loading) using System.js .
   Page load vs Lazy-loading

   When developing JavaScript code to be executed on the browser, you always have to decide WHEN you want it to be executed.
    There is always some chunk of code that must run during the page load , as for instance the structural setup of an SPA using frameworks such as Angular, Ember, Backbone or React. Such code must be referenced on the main HTML document returned to the browser after a page request, most likely through one or more 友荐云推荐




上一篇:数据平台技术指南
下一篇:Why Good Linux Sysadmins Use Markdown
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

非希风 发表于 2016-10-2 10:49:54
2016-10-02楼主还是蛮拼的。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.