Frontend development tips Flashcards
Why onSuccess/onError removed from useQuery
- An additional render cycle
- The callbacks might not run (cache)
soultion: onDataChanged in effect
https://tkdodo.eu/blog/breaking-react-querys-api-on-purpose#state-syncing
How can slow down the browser speed?
Chrome DevTools > Performance Tab
CPU = 4 *slow down or …
Which size metric is most relevant when considering the impact of a JavaScript library on a project?
The minified and gzipped size is the most relevant metric as it reflects the compressed size of the JavaScript code for efficient network transfer and optimal page loading.
https://bundlephobia.com/
what’s the categories for a system design in frontend side
- features
- non-functional requirements
- user experience
- engineering
- back in API
what things are considered in features category FE sys Design
- MVP
- high-level estimation
- core functionality
High level estimation
data volume , Peak traffic
what items are included in non-functional requirements in front end system design
- performance
- offline mode
- security
- high availability
performance
* Cache
* CDN
* load on demand or preload
* page spliting
offline mode
* local storage
* indexedDB
security
* xss
* csrf
high availability
* load balancer
* health check
Explain how JavaScript handled multiple files before the introduction of modules. What were the downsides of this approach?
multiple files could be included in a web page using multiple
tags in HTML
all scripts loaded onto the same page shared the same global scope. This meant that scripts had to be careful not to overwrite each other’s variables and functions, leading to potential conflicts and bugs
Describe the role of the “host” in the context of TypeScript module resolution and provide examples of different hosts.
the “host” is the system that ultimately consumes the output JavaScript code and directs its module loading behavior.
The TypeScript compiler models the behavior of the host to ensure correct module resolution and type checking
.Examples of different hosts:
Node.js Runtime
Bundlers
Web Browser
Webpack?
Webpack is a popular module bundler
- it compiles files into static assets that browsers can easily serve
- It handles bundling, transpiling, and optimizing assets js/css/img
performance optimization:
- code splitting, tree shaking, minification
what’s tree shaking?
-elimiate not used imports , varaibles, functions (* as lodash)
- less as possible
- in v5 - comes by default
- it only works with es6 static imports (not dynamic)
- not works with common js (require) it’s dynamic
css in js , cons, pros
like styled-components
- scoped styles
- dynamic styling
- performance runtime overhead,
- learning curve
- you can not cache the css files
- makes bundle bigger
- harder to debugg
- webpack, extract those classes and attaches in html dom in runtime