SlideShare a Scribd company logo
WEBASSEMBLY VS JAVASCRIPT:
WHAT IS FASTER?
Oleksandr Skachkov @alSkachkov
.
• Itera’s FrontEnd Tech Lead
• WebKit contributor:
• Arrow function
• Async iterator & generators
• Promise.finally
• Twitter: @alSkachkov
ABOUT ME
• What was before
• WebAssembly key features
• Is WebAssembly really fast?
• WebAssembly now
JavaScript one of the most popular language
WebAssembly vs JavaScript: What is faster?
WebAssembly vs JavaScript: What is faster?
WebAssembly vs JavaScript: What is faster?
WebAssembly vs JavaScript: What is faster?
TRIES TO REPLACE JS
asm.js
SMART PEOPLE SAYS
Always bet on JS & WASM
Always bet on JS
WASM?
WebAssembly vs JavaScript: What is faster?
• Announced in 17 June 2015
• Supported by major Browsers
• Developed by WebAssembly Working
Group (W3C)
• Draft specific published 15 Feb 2018
WebAssembly – New Hope
What is WebAssembly (aka WASM)?
WebAssembly is build target
WebAssembly vs JavaScript: What is faster?
safe, portable, low-level code format designed for efficient execution
and compact representation
https://webassembly.github.io/spec/intro
C - Source code
RUST - Source code
S - Expression
WAT?
fast to load
Byte code
WebAssembly vs JavaScript: What is faster?
Will WebAssembly replace JavaScript?
Not now J
but WebAssembly will transform web
WASM WILL BRING TO WEB
•New languages
•Predictable high performance
WebAssembly key features
HOW ENGINE WORKS
JS
WebAssembly
LOADING
LOADING
text format
<script>
blocking load
binary format
fetch
non blocking load
PARSING
text format
lazy parsing
main thread
no streaming API
binary format
S – expression
background threads
streaming API
3 2 1
5 4 3 2 1
5 4 3 2 1
PARSING
text format
lazy parsing
main thread
no streaming API
binary format
S – expression
background threads
streaming API
COMPILATION + OPTIMIZATION
main thread
optimization after
execution
background threads
offline optimization
EXECUTION
slow at start
threads - workers
no native threads
GC
close to native speed
threads – workers
native threads - future
no GC now
EXECUTION
many types
access to JS functions
access to DOM
access to Host API
only 4 primitive types
access to JS functions
no access to DOM
no access to Host API
INTERACTION WITH JAVASCRIPT
We can use JS function in WASM and WASM function in JS
IS WEBASSEMBLY REALLY FAST?
WHAT IS PERFROMANCE FOR US
• LOAD
• COMPILE
• EXECUTION
WebAssembly module is downloaded over Network
Size really matter
WASM module size expected to be smaller than js, but
SIZE OF “HELLO WORLD”
SIZE OF “HELLO WORLD”
• JavaScript – 98 bytes
• pure wasm – wasm 110 bytes + js 321 bytes
• Rust ⇒ wasm – wasm 16Kb - 600Kb + js 2 Kb
• C ⇒ emcc ⇒ wasm – wasm 22 Kb + js 99 Kb
• C#(Blazor/Mono) ⇒ wasm ~ 2 Mb
• ReactJS 16.2.0 + React DOM – 97 KB
WebAssembly is expected to be fast in compiling
COMPILING
Let’s take module and find speed in Mb per second :
• JavaScript – 16.5 Mb
• WebAssembly – 12.4 Mb
COMPILING
Streaming compiling is expected even more faster
STREAMING COMPILING
SUMMARY
• Size of WebAssembly module depends on compiler
• WebAssembly compilation is slower to js in Mb/s
• WebAssembly has streaming compilation that compile module during network delays
• WebAssembly might be parsed out of main thread
WebAssembly is expected to be fast in execution
Simple cases
Speedup of the Math operations
SPEEDUP
times
Chrome 69
SPEEDUP
times
Firefox 62
SPEEDUP
times
Safari 11.11
What if call js function from WebAssembly
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233
Fibonaccinumber
SLOWDOWNtimes
Complex case
Only 4 types
Source Map
Source Map
https://github.com/mozilla/source-map
SOURCE MAP
Crypto
CRYPTO - PBKDF2
PBKDF2 - Password-Based Key Derivation Function 2
• JS: asmcrypto.js https://github.com/asmcrypto/asmcrypto.js
• Native: Browser Web Crypto API
• WASM: Rust module with rust-crypto package
CRYPTO - PBKDF2
Convert images
Convert images
https://developer.mozilla.org/en-US/docs/WebAssembly/existing_C_to_wasm
Google Senior Developer Advocate @DasSurma
CONVERT IMAGES
• Canvas + JS:
From JPEG to BITMAP by Canvas API and to WEBP by JS (lib webpjs)
• Canvas + WASM:
From JPEG to BITMAP by Canvas API and to WEBP by WASM (lib libwebp)
• Full WASM: JPEG to WEBP by WASM (libs: libjpeg, libwebp)
CONVERT IMAGES
Times
Iterations
Why?
INTERACTION WITH JS
Performance Tab in Chrome Developer Tools
https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/
INTERACTION WITH JS
Performance Tab in Chrome Developer Tools
https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/
Can WebAssembly be faster to Host API?
sometimes, if we use WebWorkers
Can WebAssembly be faster to Host API?
sometimes, if we use WebWorkers
CONVERT IMAGES
Timetoconvert400imagesinseconds
Workers
CONVERT IMAGES
Timetoconvert400imagesinseconds
Workers
Why?
CONVERT IMAGES
• Canvas API works in main thread and blocks it
• WebAssembly does not block main thread
SUMMARY
• WebAssembly has very good performance on pure mathematics
• Call JS from WebAssembly lead to slow down of the performance
• Host API might be slower then WebAssembly in edge cases(!)
Is WebAssembly slow and useless
WHAT PROJECT FITS TO WEBASSEMLBY
• Requires a lot of computations
• Is developed with WebAssembly and high performance in mind
• Has small amount of interactions with JavaScript or DOM
• Has big C/C++ code base and high performance is not a goal
• Fast enough for Browser
WEBASSEMBLY RIGHT NOW
CAN WE USE WEBASSEMBLY?
Yes we can
How can we use WebAssembly?
USAGE SCENARIOS IN WEB
• Write faster version of the specific application
• Using existing C libraries in browser
• Reuse algorithm from service side
• Distribute whole application as wasm
• Secure your algorithms J
BUILD TARGET FOR
• C/C++
• Rust
• C# - Mono and CoreRT
• Go
• BrainFuck
• Even more: https://github.com/appcypher/awesome-wasm-langs
Ethereum Figma design
Unity Google Earth
Web Audio Modules
RESOURCES
• Articles:
• https://hacks.mozilla.org/category/webassembly/
• https://pspdfkit.com/blog/
• ategory/webassembly/
• Site: http://webassembly.org/
• Github: https://github.com/WebAssembly/
• Twitter: @WasmWeekly - WebAssemblyWeekly
EXAMPLES
• PDF Viewer: https://web-preview.pspdfkit.com/standalone
• Game: http://webassembly.org/demo/Tanks/
• Garden for Mozilla: https://s3.amazonaws.com/mozilla-
games/ZenGarden/EpicZenGarden.html (Unreal Engine 4)
• WebSight: https://websightjs.com/
• AutoCAD: https://web.autocad.com/
THANKS!
QUESTIONS?

More Related Content

What's hot (20)

PDF
Isomorphic JavaScript: #DevBeat Master Class
Spike Brehm
 
PPTX
DevDay 2018 - Blazor
Denis Voituron
 
PPTX
Breaking the eggshell: From .NET to Node.js
Barbara Fusinska
 
PPT
Bootstrapping angular js with bower grunt yeoman
Makarand Bhatambarekar
 
PDF
Building Isomorphic JavaScript Apps - NDC 2015
Eirik Vullum
 
PPTX
MEAN stack
Iryney Baran
 
PPTX
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
Irfan Maulana
 
PDF
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
Spike Brehm
 
PPTX
Into to Webassmbly
cliffzhaobupt
 
PPTX
PHP Indonesia - Nodejs Web Development
Irfan Maulana
 
PPTX
1 pluginable laravel cms
Nareerat Chan
 
PPTX
DotNet MVC and webpack + Babel + react
Chen-Tien Tsai
 
PPTX
Codegen2021 blazor mobile
Jose Javier Columbie
 
PDF
Isomorphic web application
Oliver N
 
PPTX
Building real time app by using asp.Net Core
Commit Software Sh.p.k.
 
PPTX
Blazor v1.1
Juan Luis Guerrero Minero
 
PDF
Pump up the JAM with Gatsby
Stefan Adolf
 
PDF
WebAssembly Fundamentals
Knoldus Inc.
 
PDF
The MEAN Stack
Md. Ziaul Haq
 
PDF
Build App with Nodejs - YWC Workshop
Sarunyhot Suwannachoti
 
Isomorphic JavaScript: #DevBeat Master Class
Spike Brehm
 
DevDay 2018 - Blazor
Denis Voituron
 
Breaking the eggshell: From .NET to Node.js
Barbara Fusinska
 
Bootstrapping angular js with bower grunt yeoman
Makarand Bhatambarekar
 
Building Isomorphic JavaScript Apps - NDC 2015
Eirik Vullum
 
MEAN stack
Iryney Baran
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
Irfan Maulana
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
Spike Brehm
 
Into to Webassmbly
cliffzhaobupt
 
PHP Indonesia - Nodejs Web Development
Irfan Maulana
 
1 pluginable laravel cms
Nareerat Chan
 
DotNet MVC and webpack + Babel + react
Chen-Tien Tsai
 
Codegen2021 blazor mobile
Jose Javier Columbie
 
Isomorphic web application
Oliver N
 
Building real time app by using asp.Net Core
Commit Software Sh.p.k.
 
Pump up the JAM with Gatsby
Stefan Adolf
 
WebAssembly Fundamentals
Knoldus Inc.
 
The MEAN Stack
Md. Ziaul Haq
 
Build App with Nodejs - YWC Workshop
Sarunyhot Suwannachoti
 

Similar to WebAssembly vs JavaScript: What is faster? (20)

PPTX
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JSFestUA
 
PDF
WebAssemlby vs JavaScript
Alexandr Skachkov
 
PDF
WebAssembly - The Journey (BrazilJS 2017 talk)
Elia Maino
 
PDF
WebAssembly - kolejny buzzword, czy (r)ewolucja?
Brainhub
 
PDF
WebAssembly - czy dzisiaj mi się to przyda do pracy?
Brainhub
 
PPTX
WebAssembly: In a Nutshell
RangHo Lee
 
PDF
Web assembly brings the web to a new era
Boyan Mihaylov
 
PPTX
The Rise of WebAssembly Transforming Web Development for the Modern Era.pptx
SoftflixIT
 
PPT
Web assembly overview by Mikhail Sorokovsky
Valeriia Maliarenko
 
PDF
Do things faster and better with WebAssembly - Sendil Kumar Nellaiyapen - Cod...
Codemotion
 
PDF
Web Assembly
Valerio Como
 
PDF
Boyan Mihaylov - Is web assembly the killer of javascript
Codemotion
 
PDF
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov
 
PPTX
Building Web Apps with WebAssembly and Blazor
Amir Zuker
 
PDF
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
CodeValue
 
PDF
Web (dis)assembly
Shakacon
 
PDF
Start writing in WebAssembly
The Software House
 
ODP
An Introduction to WebAssembly
Daniel Budden
 
PPTX
Web assembly: a brief overview
Pavlo Iatsiuk
 
PPTX
Quick overview of WebAssembly
Karl Ritchie
 
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JSFestUA
 
WebAssemlby vs JavaScript
Alexandr Skachkov
 
WebAssembly - The Journey (BrazilJS 2017 talk)
Elia Maino
 
WebAssembly - kolejny buzzword, czy (r)ewolucja?
Brainhub
 
WebAssembly - czy dzisiaj mi się to przyda do pracy?
Brainhub
 
WebAssembly: In a Nutshell
RangHo Lee
 
Web assembly brings the web to a new era
Boyan Mihaylov
 
The Rise of WebAssembly Transforming Web Development for the Modern Era.pptx
SoftflixIT
 
Web assembly overview by Mikhail Sorokovsky
Valeriia Maliarenko
 
Do things faster and better with WebAssembly - Sendil Kumar Nellaiyapen - Cod...
Codemotion
 
Web Assembly
Valerio Como
 
Boyan Mihaylov - Is web assembly the killer of javascript
Codemotion
 
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov
 
Building Web Apps with WebAssembly and Blazor
Amir Zuker
 
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
CodeValue
 
Web (dis)assembly
Shakacon
 
Start writing in WebAssembly
The Software House
 
An Introduction to WebAssembly
Daniel Budden
 
Web assembly: a brief overview
Pavlo Iatsiuk
 
Quick overview of WebAssembly
Karl Ritchie
 
Ad

Recently uploaded (20)

PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Ad

WebAssembly vs JavaScript: What is faster?