WEB


  Understand Virtual DOM

With the popularity of React, the internals and implementation of Virtual DOM has becoming top discussed topic in tech communities and interviews. This post will give an introduction of Virtual DOM and how to implement a simple Virtual DOM logic.How to understand Virtual DOMIn early days, front end developers would update a webpage view based on the data status change(usually after making AJAX call). But it brings performance penalties when there is frequent update as it would cause page reflow and repaint and in turn lead to page stuck.Hence people comes out a solution which is to just update...

9,245 1       JAVASCRIPT DOM VIRTUAL DOM


  CSS position explained

CSS has two very important properties on determining the position of an element in webpage: display and position. display is used to determine how elements are grouped and displayed on the page. While position is used to determine the exact position of an element on a page. And this post would explain position property in detail.position is used to determine the exact position of an element on a page. It has five possible values.staticrelativeabsolutefixedstickysticky is supported starting from 2017 in browsers and it would be explained more later.staticstatic is the default value of the posit...

12,374 3       CSS STICKY CSS3


  The evolving history of asynchronous operation in JavaScript

JavaScript is single threaded, it means there would be only one task running at any point of time. But this would slow down the overall program execution if there is long running task, hence asynchronous task execution is desired in complex cases. To achieve asynchronous task execution, there are a few options introduced in JavaScript.setTimeout/setIntervalEventPromiseAsync/AwaitsetTimeout/setInterval is one of the first mechanisms introduced in JavaScript to simulate asynchronous operations. Since these operations are not executing in sequence, there would be a potential issue on how data/sta...

5,922 0       AWAIT JAVASCRIPT ASYNC PROMISE


  A small trick on using console.log to print data in JavaScript

When debugging JavaScript application, one may frequently use console.log to print data so that it is easy to debug when issue occurs and also helps on understand the data flow. The common way of printing a variable would be something like. let user = { name: "test"};console.log(user);In this case it will print:{ name: 'test' }This is OK when there is no much logging or the program is not complicated. But it becomes difficult to debug if there are lots of variables to be printed as there is no clear indication on which variable or object it is.So in this case one may add some extra log...

13,651 4       DEBUGGING CONSOLE.LOG JAVASCRIPT


  Use CSS calc to align an element vertically

calc function is a function introduced in CSS3, it can be used to calculate length values. There are a few good features which make it suitable for aligning an element vertically.One good part is that the operands can have different units like percentage, px, rem etc. This makes it very flexible when calculating the length value. One example:.rect{ margin-top:20px; height:50px; background:green; width:calc(100%-20px);}Here the left operand uses percentage while the right one uses px, they can work perfectly without any conflict.The result of calc is dynamic but not pre -calculated....

11,534 1       CSS3 CALC VERTICAL ALIGN


  How to use Chome dev tool to find event handler bound to an element

As a front end developer, there is frequent need to debug JS code and sometimes need to find out what event handler has been bound to a HTML element. In this post, we will show how to find out the click event handler bound to a HTML element, this same applies to other events as well.Nowadays, a web application is usually very complicated and there are lots of JS codes which makes it difficult to find out what click event handler has been bound to a HTML element, especially when the JS source code has been obfuscated or compressed.By using Chrome, it becomes relative easy to find out this kind ...

8,873 0       JAVASCRIPT CHROME CHROME DEV TOOL EVENT LISTENER


  How to monitor user behavior in webpage

Sometimes there is a need for website owners to monitor user behavior on the site so that they can know what pages are mostly visited and which parts are more popular so that they can provide better service to their users. These behavior usually contain user clicks, user mouse over events etc. These data can be sent back to server when triggered with some meta data.In this post, we will cover a few ways to monitor user behavior on a web portal and send data back to backend sever.1. Synchronous AJAXA common way to send data back to backend server is using AJAX to send the data in the page unloa...

3,006 0       PING USER BEHAVIOR BEACON API HTML


  A mini guide to HTTP referer

In HTTP header, there is a field named Referer which is to provide the referrer of the current accessed page. In this post, we will introduce the usage of HTTP referer field.On the web, when a user visits a webpage, s/he must be from some place. This place is usually referred a s referer. This information is very important to some website operators and server owners as they want to know where they get the traffic from and this helps them provide better service for potential targeted users.In the request header of a HTTP request, there is a Referer filed which can be set to the referrer URL ind...

119,261 0       REFERRERPOLICY HTTP REFERER HTML