3/24/17
and fixing!
Charlie King
Ed Atrero
Thomas Duffy
"Nearly half of web users expect a site to load in 2 seconds or less, and they tend to abandon a site that isn’t loaded within 3 seconds"
source: Akamai and Gomez.com
15.5MB of images
140 x 140px
Use 250X250px logos
<wm-brand-card
class="scroll-card brand-card home"
ng-repeat="brand in ::category.brands"
brand="brand"
subtitle-name="Products"
image="{{ brand.avatar_image.large_url }}"
ng-click="category.clickCategoryCard($index, brand)">
</wm-brand-card>
<wm-brand-card
class="scroll-card brand-card home"
ng-repeat="brand in ::category.brands"
brand="brand"
subtitle-name="Products"
image="{{ brand.avatar_image.small_url }}"
ng-click="category.clickCategoryCard($index, brand)">
</wm-brand-card>
REMOVED FONT AWESOME
SAVED 100KB
USED PROPERLY SIZED BRAND IMAGES
SAVED 6.5MB
ME
Next Steps
save 70% by using 140x140 images
http://www.pcmag.com/encyclopedia/term/39177/cache
Deliveries
Brands
User Location
Dispensaries
Doctors
Ad server
Wayso
weedmaps tv
Currently
the user has to wait while we do our data calls and watch a loading animation.
The first time the user hits our site, we save their location and data calls on their device.
The next time the user visits the site, we immediately load the cached data and replace it after the network calls come back.
Local Storage
Updated data from servers
Cached data UX
Cached
Not Cached
~7s before seeing cards
~1s before seeing cards
Desktop seems okay.. Maybe we are using too much memory (which my phone has much less of) ?
Chrome -> Window -> Task Manager
~250MB Native Allocations (DOM Nodes)
~90MB JS Heap Allocations (our JS code)
~3,000 DOM Nodes
We create too many DOM nodes. ~3,000 depending on the region
Creates high initial memory usage, then too much GC pressure
Reduce total card count per category (listings, brands) to 5
220MB Native Allocations (DOM Nodes)
68MB JS Heap
2,106 DOM Nodes
Try to figure out where time is being spent.
Flame graphs to the rescue!
Chrome -> DevTools -> Timeline -> Record
133ms Compile
369ms Eval
Our vendor bundle is very large, takes time to parse and compile
Homepage animation setup is one of our longest running user-land functions.
34ms on-cpu
Map spends the most time decorating listings
~20-30ms on-cpu
Flame graphs are great for finding hot functions to optimize
✅ Remove JS based animation for homepage
🔲 Optimize decorateListings function
Reduce the size of the vendor bundle to decrease parse/compile times
Moonshot will cut this by ~50%
Are we causing re-layout and reflow on the page? Or how many times is the DOM being updated?
Chrome -> DevTools -> Timeline -> Record
reflow
reflow
reflow
reflow
Too many re-layout operations
Timeline tool also shows re-layout operations
Batch all operations by loading in-memory and NOT attaching to Angular Scope until complete -> 1 layout operation
Load more data in a single request (within reason), e.g. top 5 listings for each type in a single call
Serve HTML!
Moonshot will serve HTML from NodeJS
Multiplexing e.g. multiple requests to the same origin at the same time!
Old and busted
New hotness
Core API / WmAPI - 🚫
MapBox Map Tiles - 🚫
Ionic static assets ✅
Core static assets ✅
Image server ✅
Static map tile server (going away) ✅
Avatar CF/S3 assets ✅
Server Push
Possible with updates to Cloudfront and/or Moonshot