Posts

Showing posts with the label learn javascript

How to optimise performance of a web-site or mobile site

These are all the points which can boost up your website performance. Below are just bullet points. I'll be touching each of these point every week. Stay tuned for more info. Http2 multiplexing, header compression and other features like server push Rather than showing a loader, show a rendered page(did not mean interactive). Something like server side rendering. Adding more to point 2. Push interactive state away and try to render as early as possible. Code chunks, lazy loading. Css splitting, should be route and component based. DNS resolution ?  Omitting option call. To load only useful code, rest can be loaded later when resources are free. Minify css Dns preconnect Code splitting, js and css Preloading and prefetching Image sprite using grunt Prepond API call Reduce the number of bundle JS code which can delayed, should be delayed MJS Compression: Gzip vs Brotli CDN Critical rendering CSS Service worker: Caching, prefetching Web ...

Regular expressions tricks and tips

Regex: Literal characters:  Alphanumeric character: itself \o: null character \t: tab \n: newline \v: vertical tab \f: form feed \r: carriage return \x nn: Latin character specified by a hexadecimal number \u xxxx: Unicode character specified by the hexadecimal number \c X: Control character  Character classes:  /[abc]/-  Any of a, b or c. /[^abc]/- None of a, b and c. /[a-z]/- Any char from a to z. /[a-zA-Z0-9]/- Any char from a-z, A-Z or 0-9. Note: ^ and $ have different meaning inside character classes. ^ means negation and $ behaves like a usual dollar symbol Eg: /a[b$]/: a$ or ab  Clasess: /w:  /[a-zA-Z0-9_]/ Any char from a-z, A-Z or 0-9. /W:  /[^a-zA-Z0-9_]/ Any char other than a-z, A-Z or 0-9. /s: Unicode whitespace /S: Any char other than whitespace charac /d: /[0-9]/ Any ascii digit /D: /[^0-9]/  [\b]: A literal backspace Repetition: {n,m}: Match the previous item at least n times but no more...

Array methods tips and tricks

shift and unshift arr.shift() – extracts an item from the beginning, arr.unshift(...items) – adds items to the beginning. splice:  The arr.splice(str) method is a swiss army knife for arrays. It can do everything: insert, remove and replace elements. arr.splice(index[, deleteCount, elem1, ..., elemN]) thisArg: Almost all array methods that call functions – like find, filter, map, with a notable exception of sort, accept an optional additional parameter thisArg. arr.find(func, thisArg); arr.filter(func, thisArg); arr.map(func, thisArg); // ... // thisArg is the optional last argument The value of thisArg parameter becomes this for func. concat: arr.concat(arg1, arg2...) argN: not always an array If an argument argN is an array, then all its elements are copied. Otherwise, the argument itself is copied. Eg: let arr = [1, 2]; alert( arr.concat([3, 4])); // 1,2,3,4 alert( arr.concat([3, 4], [5, 6])); // 1,2,3,4,5,6 alert( arr.concat([3, 4], 5, 6)); // 1,2,3,4,5,6 //one arg is an...