SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
PRIMARY
#2D3442
SECONDARY
#F90032
TERTIARY
#F3F3F3
use for text creation and items such as shapes and forms only use shapes and background items
delete this slide after read or if you don't need it
the outsider javascript framework
Claudio Bisconti
Principal Engineer @ MotorK
Technology fanatic
Apple addicted
Alpine.js
Tailwind%20CSS
lover
Vue.js
React
Laravel
expert
WordPress unfortunately expert
Alpine.js
Simple.
Lightweight.
Powerful as hell.
Alpine.js
The origins
State (JavaScript data that Alpine watches for changes)
How alpine.js work?
<section x-data="{ open: false }">
<button @click.prevent="open = !open">
Toggle button
</button>
<div x-show="open" x-cloak x-data="{ label: 'Content:' }">
<span x-text="label"></span>
<p x-ignore>
Whathever you write here is ignored by Alpine.js lifecycle
</p>
</div>
</section>
Alpine is a collection of
● 18 attributes
● 9 magic properties
● 3 global methods
Let’s check the docs together
Documentation
Documentation showcase
Official must to use plugins
Feature name NPM package name Alpine feature
intersection observer @alpinejs/intersect x-intersect
persist @alpinejs/persist
Save the Alpine.Store into the
localStorage
focus @alpinejs/focus x-trap
collapse @alpinejs/collapse x-collapse
Adding a new “Component”
window.myTabs = () => ({
selectedTab: 0,
setTabIndex: (i) => {
this.selectedTab = i
},
init: (i = 0) => {
this.setTabIndex(i)
}
})
<section x-data="myTabs(4)" x-init="init(2)">
<div class="tabs-header">
<button class="tab" @click="setTabIndex(0)">
…
</div>
<div class="tabs-content">
<div class="tab-0" x-show="selectedTab == 0">
...
</div>
...
</div>
</section>
Adding a new “Component”
const myTabs = () => ({
selectedTab: 0,
setTabIndex: (i) => {
this.selectedTab = i
},
init: (i = 0) => {
this.setTabIndex(i)
}
})
Alpine.directive(‘tabs’, myTabs);
<section x-tabs x-init="init(2)">
<div class="tabs-header">
<button class="tab" @click="setTabIndex(0)">
…
</div>
<div class="tabs-content">
<div class="tab-0" x-show="selectedTab == 0">
...
</div>
...
</div>
</section>
Adding a new “magic” component
Alpine.magic('clipboard', () => {
return subject => navigator.clipboard.writeText(subject)
})
// HTML usage
<button @click="$clipboard('hello world')">
Copy "Hello World"
</button>
Using in a ES6 context
import Alpine from 'alpinejs'
// Optional
window.Alpine = Alpine
// Register plugins and custom features
Alpine.start()
When you add HTML into the DOM,
all the Alpine.js components
will be automatically initialized
Surprised by the MutationObserver
Since Alpine it works directly into the HTML without bundlers…
You can use it also in production without hacks.
https://chrome.google.com/webstore/detail/alpinejs-devtools/fopaemeedckajflibkpifppcankfmbhk
Devtools
Livewire is a full-stack framework
for Laravel that makes building
dynamic front-ends as simple as
writing vanilla PHP (literally).
How we changed frontend
approach with alpine.js
We added the x-defer directive to Alpine
Dynamic modules
window.components = window.components || [];
window.components.push = function (obj) {
window.components[window.components.length] = obj;
loadModule(obj);
}
window.components.forEach(obj => loadModule(obj));
Alpine.js
Conclusions
Pro
● No bundlers needed
● Easy to use
● Near to Vue syntax
● It simplify the work on
small projects
Cons
● No SPA/Routing support
● It requires discipline
(to avoid spaghetti code)
● Is not a magic wand
Pro and cons table
That’s all.
Questions?
Software developer
Claudio Bisconti
claudio.bisconti@gmail.com

Weitere ähnliche Inhalte

Was ist angesagt?

Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 

Was ist angesagt? (20)

CSS
CSSCSS
CSS
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts Basics
 
HTML
HTMLHTML
HTML
 
CSS Positioning Elements.pdf
CSS Positioning Elements.pdfCSS Positioning Elements.pdf
CSS Positioning Elements.pdf
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP (Partie II) Par Mahdi Ben Alaya
PHP (Partie II) Par Mahdi Ben AlayaPHP (Partie II) Par Mahdi Ben Alaya
PHP (Partie II) Par Mahdi Ben Alaya
 
Introducción a php
Introducción a phpIntroducción a php
Introducción a php
 
Php forms
Php formsPhp forms
Php forms
 
An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Les balises HTML
Les balises HTMLLes balises HTML
Les balises HTML
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
 
Odoo - Create themes for website
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for website
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 
RDF data validation 2017 SHACL
RDF data validation 2017 SHACLRDF data validation 2017 SHACL
RDF data validation 2017 SHACL
 
Css
CssCss
Css
 

Ähnlich wie Alpine.js: the outsider Javascript framework

Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
Scott Messinger
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
sblackman
 
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Techsylvania
 
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docxCalculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
RAHUL126667
 

Ähnlich wie Alpine.js: the outsider Javascript framework (20)

Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Using Renderless Components in Vue.js during your software development.
Using Renderless Components in Vue.js during your software development.Using Renderless Components in Vue.js during your software development.
Using Renderless Components in Vue.js during your software development.
 
iWebkit
iWebkitiWebkit
iWebkit
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
 
Single page webapps & javascript-testing
Single page webapps & javascript-testingSingle page webapps & javascript-testing
Single page webapps & javascript-testing
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Magento++
Magento++Magento++
Magento++
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docxCalculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Adding powerful ext js components to react apps
Adding powerful ext js components to react appsAdding powerful ext js components to react apps
Adding powerful ext js components to react apps
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 

Mehr von Commit University

Mehr von Commit University (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting for
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
 
SwiftUI vs UIKit
SwiftUI vs UIKitSwiftUI vs UIKit
SwiftUI vs UIKit
 

Kürzlich hochgeladen

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Alpine.js: the outsider Javascript framework

  • 1. PRIMARY #2D3442 SECONDARY #F90032 TERTIARY #F3F3F3 use for text creation and items such as shapes and forms only use shapes and background items delete this slide after read or if you don't need it
  • 3. Claudio Bisconti Principal Engineer @ MotorK Technology fanatic Apple addicted Alpine.js Tailwind%20CSS lover Vue.js React Laravel expert WordPress unfortunately expert
  • 6. State (JavaScript data that Alpine watches for changes) How alpine.js work? <section x-data="{ open: false }"> <button @click.prevent="open = !open"> Toggle button </button> <div x-show="open" x-cloak x-data="{ label: 'Content:' }"> <span x-text="label"></span> <p x-ignore> Whathever you write here is ignored by Alpine.js lifecycle </p> </div> </section>
  • 7. Alpine is a collection of ● 18 attributes ● 9 magic properties ● 3 global methods Let’s check the docs together Documentation Documentation showcase
  • 8. Official must to use plugins Feature name NPM package name Alpine feature intersection observer @alpinejs/intersect x-intersect persist @alpinejs/persist Save the Alpine.Store into the localStorage focus @alpinejs/focus x-trap collapse @alpinejs/collapse x-collapse
  • 9. Adding a new “Component” window.myTabs = () => ({ selectedTab: 0, setTabIndex: (i) => { this.selectedTab = i }, init: (i = 0) => { this.setTabIndex(i) } }) <section x-data="myTabs(4)" x-init="init(2)"> <div class="tabs-header"> <button class="tab" @click="setTabIndex(0)"> … </div> <div class="tabs-content"> <div class="tab-0" x-show="selectedTab == 0"> ... </div> ... </div> </section>
  • 10. Adding a new “Component” const myTabs = () => ({ selectedTab: 0, setTabIndex: (i) => { this.selectedTab = i }, init: (i = 0) => { this.setTabIndex(i) } }) Alpine.directive(‘tabs’, myTabs); <section x-tabs x-init="init(2)"> <div class="tabs-header"> <button class="tab" @click="setTabIndex(0)"> … </div> <div class="tabs-content"> <div class="tab-0" x-show="selectedTab == 0"> ... </div> ... </div> </section>
  • 11. Adding a new “magic” component Alpine.magic('clipboard', () => { return subject => navigator.clipboard.writeText(subject) }) // HTML usage <button @click="$clipboard('hello world')"> Copy "Hello World" </button>
  • 12. Using in a ES6 context import Alpine from 'alpinejs' // Optional window.Alpine = Alpine // Register plugins and custom features Alpine.start()
  • 13. When you add HTML into the DOM, all the Alpine.js components will be automatically initialized Surprised by the MutationObserver
  • 14. Since Alpine it works directly into the HTML without bundlers… You can use it also in production without hacks. https://chrome.google.com/webstore/detail/alpinejs-devtools/fopaemeedckajflibkpifppcankfmbhk Devtools
  • 15. Livewire is a full-stack framework for Laravel that makes building dynamic front-ends as simple as writing vanilla PHP (literally).
  • 16. How we changed frontend approach with alpine.js
  • 17.
  • 18.
  • 19. We added the x-defer directive to Alpine Dynamic modules window.components = window.components || []; window.components.push = function (obj) { window.components[window.components.length] = obj; loadModule(obj); } window.components.forEach(obj => loadModule(obj));
  • 21. Pro ● No bundlers needed ● Easy to use ● Near to Vue syntax ● It simplify the work on small projects Cons ● No SPA/Routing support ● It requires discipline (to avoid spaghetti code) ● Is not a magic wand Pro and cons table