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
JavaScript Modules & Current Updates
Search
Rizqy Hidayat
November 23, 2021
Programming
0
91
JavaScript Modules & Current Updates
Rizqy Hidayat
November 23, 2021
Tweet
Share
More Decks by Rizqy Hidayat
See All by Rizqy Hidayat
HTMX: Back to Basic
rizqyhi
0
53
Exploring PEMPA Architecture on Dicoding.com
rizqyhi
0
32
Menjelajah Dunia Frontend Lebih Jauh
rizqyhi
0
17
Introduction to Open Source & Hacktoberfest
rizqyhi
0
110
Frontend is Enough
rizqyhi
0
30
Other Decks in Programming
See All in Programming
KagglerがMixSeekを触ってみた
morim
0
240
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
470
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
160
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
240
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.7k
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
1.3k
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.5k
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
550
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
500
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
600
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
980
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
91
GraphQLとの向き合い方2022年版
quramy
50
14k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
91
エンジニアに許された特別な時間の終わり
watany
106
240k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
150
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
220
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Deep Space Network (abreviated)
tonyrice
0
95
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Transcript
JavaScript Modules & Current Updates Rizqy Hidayat PRODUCT ENGINEER, DICODING
Aloha 👋 Rizqy Hidayat PRODUCT ENGINEER, DICODING
[email protected]
- @rizqyhi
Prehistoric module Era 🦕 • • • JavaScript doesn't have
built-in support for modules Modular files, global scope Dependencies should be loaded before and configured manually
None
COMMONJS AMD UMD ESM Used in NodeJS (server) Used in
browser (client) Works for both node & browser Newest stanndard on ES6 ✨ History of Modules in JavaScript
CommonJS • • • Standard used in NodeJS for working
with modules Load modules synchronously Simple syntax
Asynchronous Module Definition (AMD) • • • • Alternative to
CommonJS, usually used in browser Needs library to handle module resolution Load modules asynchronously Slightly complex syntax
What if our library used by many teams? And they
used CommonJS and AMD?
Universal Module Definition (UMD) • • • Unify CommonJS and
AMD More complex syntax Use build tool to help generate exported modules
None
EcmaScript Module (ESM) • • • • Part of ES6/ES2015
standard The best from both CommonJS and AMD: Simple syntax Load module asynchronously
Use ESM in Browser Now • • • Import directly
from file/CDN No transpilation needed No need to bundle
None
Does it work on old browsers? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
ESM in Older Browser • • • Write code in
ES6 Transpile to ES5 Bundle into one file or split into chunks
Takeaways • • • • • Use ESM to work
with modules Write JavaScript in newest standard Or TypeScript if necessary Transpile to older format when in needs to support old browsers Use best tools available that suites your needs
Thanks!