“If your website takes longer than 3 seconds to load, you could already be losing nearly half of your visitors”
Performance is one of the most critical aspects of any web project and plays a major role in the success of any online venture. Your site may have the best services, products, and content found on the web, but if your site performance is off, you’re hurting your brand and driving users to the competition.
How can we make sure that performance is not going to hold us back from success?
Join me in this session as we tackle these big questions head-on and unravel different approaches and practices that will assist you in writing highly performant web apps as is expected today.
4. Why should I even care?
Performance issues directly affect the end users experience
4
Slow website speed turns users off
Slow websites cost money and damage reputation
5. 5
1 second delay means 7% reduction in conversions
1 second delay means 11% loss of page views (SEO)
Let’s get statistical (Hubspot research)
47% of the users expects a website to load < 2sec
Page slowdown of 1 second could cost Amazon $1.6 billion/year
79% of users who experience poor performance are less likely to visit again
6. You won’t get a
second chance
when it comes to
user experience
“
“
7. 7
High-performant websites results in :
Higher traffic
High return visits
Low bounce rates
Higher conversions
Higher engagement
Higher ranks in organic search
11. 11
Not everything is important for everybody
Different needs for different users
Different needs for different devices
Different needs for different systems
18. 18
Goals
Under 5s Time to Interactive for 3G
Under 170 KB of critical path resources (compressed/minified)
19. 19
Actions that were taken
Upgrading Angular version - Ivy
Lazy loading modules
Assets Size – trivial but critical, images optimization
Fast hosting , compression and CDN
More….
20. 20
Know your Bundles!
Look for unused packages
Replace large packages if possible
Remove unnecessary imports
21. 21
Using webpack-bundle-analyzer
> npm install -g webpack-bundle-analyzer
> ng build --stats-json
> webpack-bundle-analyzer “../dist/my-performant-project/stats.json“
Webpack Bundle Analyzer is started at http://127.0.0.1:8888
22. Introducing performance “Budgets”
22
Set and Monitor bundle size thresholds
Performed at build time
Integrated as part of CI/CD
Highlight the impact of heavy assets
23. 23
“Budges” types
Bundle - The size of a specific bundle
Initial - The initial size of the app
All - The size of the entire app
25. 25
WARNING in budgets, maximum exceeded for main. Budget 150 kB was exceeded by 218 kB.
ERROR in budgets, maximum exceeded for main. Budget 200 kB was exceeded by 168 kB.
> ng build --prod
26. Using Lighthouse for performance “Budgets”
26
Monitor performance metrics at run time
Provides metrics to track whole team work
Can be integrated as part of CI/CD
Aligned the team around common metric goals
29. 29
Introducing “App shells”
Provides a fast first impression
Provide the user with the perception of a faster page load
Launching a static rendered page while the browser loads assets
30. 30
Angular App Shell
> ng new app-shell-example --routing
> ng add @nguniversal/express-engine --client-project app-shell-example
> ng run app-shell-example:app-shell
> ng generate app-shell --client-project app-shell-example --universal-project
app-shell-example-server
33. 33
Lazy loading with Preloading Strategy
Loading Lazy Modules asynchronously in the background
User do not have to wait for a lazy module to be downloaded
37. 37
Loading Strategy
Eagerly Load the modules required at startup
Preload all frequently used modules, may be after some delay
Lazy load remaining modules
38. 38
Takeaways
High performant web apps is a combination of
Art Best Practices Sleight Of Hand
Set a shared goals and be creative
Understand your user’s needs
Make performance a business priority