Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Vanilla JS challenge
Search
tomoaki kanayama
February 11, 2024
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vanilla JS challenge
tomoaki kanayama
February 11, 2024
More Decks by tomoaki kanayama
See All by tomoaki kanayama
Gemini API で デロリアン
aknow2
0
160
Other Decks in Programming
See All in Programming
Event is what happens
moro
2
3.9k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
170
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
160
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
360
Performance Optimization With LLMs
xleitix
0
250
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
4
1.5k
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
290
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
180
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
300
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
200
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
8.8k
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.3k
Automating Front-end Workflow
addyosmani
1370
210k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
How to build a perfect <img>
jonoalderson
1
6.2k
Unsuck your backbone
ammeep
672
58k
Designing Powerful Visuals for Engaging Learning
tmiket
1
650
Done Done
chrislema
187
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
570
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Transcript
Vanilla JS challenge 金山智昭
だれ 金山智昭 (Kanayama Tomoaki) 三重県津市在住のプログラマーです Frontend(React, Vue, webgl) Apps (Electron,
ReactNative) Cloud (AWS, Firebase, Supabase) Backend (django, RoR) GeoVisualization Agile
去年末のある日 https://www.youtube.com/shorts/91WgzdDF3yk
アプリにしたら楽しそう
作った https://6-ro.com
今回開発する上での縛り 1. ブラウザで動作するWebアプリ プラットフォームとか考えるとネイティブ面倒 HTMLとjsのみで動作する 2. Vanilla jsで行く http://vanilla-js.com/ 要は全部自分で書く
モチベーション ReactとかVue、Three, p5とか.jsはもうお腹いっぱい 最近はWeb標準のAPIでも色々出来るようになってきている FWを使わずに、Web標準でどこまで快適に行けるか試してみよう
開始10分後
ただし、色々面倒なので以下は使う Vite 開発体験向上(HMR, Bundler, unittest) Typescript WebGL回りはコードがゴチャるのでTypescriptがあった方が安心 というかChatGPTが吐いたコードが、、、
Vanilla.jsで試したい事 コンポーネント指向の開発 AngularやVue,Reactでの流行り始めたやつ UI(ボタン、フォーム)とかパーツかして使い回せる様にして開発する 従来はCSSで実現してたが、DOMや振る舞いまで使い回せるところが違う Reactive 値が変わったら勝手にUIが更新されるよ!ってやつ(後述) CSS SCSSいらん CSS
in JSもいらん WebGL WebGPU WebGL2 WebGL
コンポーネント指向の開発 React // index.jsx function HelloWorld(props) { return <span className="title">Hello!
{props.name}<span> } function Root() { return <div> <HelloWorld name="world"> <HelloWorld name="vanilla js"> </div> }
コンポーネント指向の開発 Web component <!-- DOMを独自に定義 --> <hello-world name="world"> <hello-world name="Vanilla
JS"> class HelloWorld extends HTMLElement { connectedCallback() { const shadow = this.attachShadow({ mode: 'closed' }); // このコンポーネント専用のCSSが書ける shadow.innerHTML = /* html */ ` <style> span { text-align: center; } </style> <span>Hello ${ this.name }!</span>`; } } defineComponent('hello-world', HelloWorld)
Reactive 状態が変わったら勝手にUIが更新される Excelの表を想像
Reactive Web component <Counter id="counter" count="0"></counter> class Counter extends HTMLElement
{ // 属性の値が変わったら更新される attributechangedcallback() { const shadow = this.shadowRoot; const count = this.getAttribute('count') shadow.innerHTML = /* html */ ` <span>Count: ${ count }!</span>`; } } const counter = document.getElementById('counter') counter.setAttribute("count", "6")
Reactive 状態管理 特に目新しい事が無くて、面白味がないので割愛 いわゆるObserberパターンで実装
CSS コンポーネントに閉じられるので、名前被りの心配は要らない(BEMとか要らない) グローバルなCSSが出来ないのが逆に面倒。色とかは、共通CSSを準備して全ての コンポーネントで読み込んでいる。かなり冗長 CSSのネストもサポートされはじめたしSCSSは不要では?
WebGL WebGPUを使ってみたかったが、Safariとかが未対応だったのでWebGL2を採用 正直、簡単に書きたいならライブラリ使った方が良い Shaderで細かく調整したいなら、生で書いた方が楽そう 特に今回は全体を回転させたり、特殊な事を色々したかったので、ライブラリ使 わずにやったのは正解だった気がする # vertex ... void
main() { ... mat2 rotation = mat2(c, -s, s, c); gl_Position = vec4(rotation * a_position, 0.0, 1.0); } # fragment void main(){ gl_Frag_color = v_color; }
まとめ FWのバージョンアップに悩まされないし、趣味で書くにはフレームワーク要らな いんじゃね?とはなる まともに仕事で開発しようと思ったら、まだまだ辛い チームで開発するにはオレオレフレームワークにせざるを得ないので、規律を決 めるのが面倒そう
None