Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Atom
Search
Alibaba.com
May 31, 2013
Technology
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Atom
Atom is growing up
Alibaba.com
May 31, 2013
More Decks by Alibaba.com
See All by Alibaba.com
jQuery Selector 源码剖析
alibaba
0
170
Backbone.js 初探
alibaba
2
260
Other Decks in Technology
See All in Technology
[ホンマでっか SRE] あなたはなぜ SRE に?
_awache
0
340
Claude Teamプランの コスト最適化を考える
rfdnxbro
0
800
Digital Credentials API × OpenID4VP ブラウザ完結型本人確認の実装知見(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
330
Dylib Hijacking on macOS: Dead or Alive?
patrickwardle
0
130
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3.2k
アクセスキー流出時の対応で再認識した攻撃側と防御側の非対称性について
kazzpapa3
0
440
When Token Pruning is Worse than Random: Understanding Visual Token Information in VLLMs
sansantech
PRO
0
130
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
5k
dbt in Microsoft Fabric
ryomaru0825
0
300
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
130
Distributed Transactions Under Fire: Building a Zero-Oversell Flash Sale Platform with Amazon Aurora DSQL
yama3133
0
100
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
24k
Featured
See All Featured
Everyday Curiosity
cassininazir
0
300
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
220
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
220
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
390
Designing Powerful Visuals for Engaging Learning
tmiket
1
510
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
260
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Bash Introduction
62gerente
615
220k
Transcript
Atom is Growing Up!
Atom 阶段回顾 连沁 2013-05-31
强调下模块编写/引用的规范
• 模块编写 使用 CMD 模块规范,每个js文件就是一个模块 模块使用 匿名方式 编写 • 模块之间引用
引用 自身的私有模块 ,使用 相对路径 引用 其他的公用模块 ,使用 以htdocs为根目录的绝对路径 禁止引用其他模块的私有模块!!! • html/vm 引用模块 禁止在非js文件中定义模块!!! 引用模块只能使用 seajs.use 接口, 禁止使用script标签同步引入!! 引用模块使用 全路径 ,推荐使用 #stamp 宏包裹,保证时间戳准确
开发中一些常见问题
为什么js里不能使用seajs.use? • 首先,规范 • 在seajs的模式里面,所有的js文件都是 CMD 模块。 • 而在 CMD
模块中,对模块的引用只能通过 require() 及 require.async() 的方式, seajs.use的用法是 不符合规范 的
为什么js里不能使用seajs.use? • 其次,性能 • 正常的使用 `seajs.use` 去加载文件,流程如 下 • ...
| | - 在 html/vm 里写 seajs.use 去请求模 块(js文件) ====异步===> 模块 ====> 运 行 callback | | - 其他html渲染,script运行等 | ... 除了 atom.js 以外所有的js文件都是 异 步加载 的
看看demo与结果
i18n相关 • 设置页面i18n • <script type='text/javascript'> // 页面中越早 调用越好 //
建议在引入 atom.js 之后马上设 置 seajs.setLocale(locale); </script>
i18n相关 • 模块里使用i18n • 使用 {locale} 来代替 i18n 中标识语言的部分 •
使用变量代替在 require 中的位置 (该用法是 为了解决独角兽时间戳失效的问题,独角兽端 的修复在7月份解决) • // 时间戳问题修复前,要这么使用 // #require "i18n/en-us.js" // #require "i18n/zh-cn.js" // #require "i18n/zh-tw.js" var i18nStr = './i18n/{locale}.js'; var i18n = require(i18nStr) || {}; // 时间戳问题解决后(2013-07完成),这 么使用 var i18n = require('./i18n/{locale}.js') || {};
Combo相关 • 页面上可以在任何地方使用seajs.use,最终 请求会在domReady的时候统一 Combo后 发 出 • 可以使用 seajs.flush()
提前发出请求(一般 用于首屏优化) • url过长的时候会自动拆分成多个 • 做完combo后的页面至少有2个串行的js请 求
Q & A