Javascript And Other Client Scripting

Use Web Workers to Do the Script-intensive Work in the Background

Web Workers allow you to run JavaScript code in the background without blocking the web page user interface. Web workers can improve the overall performance of a web page and also enhance the user experience. In the example below, the intensive work is in the script lengthytask.jsand it is invoked

How to Measure the Performance of a Script in JavaScript

We can now use the Performance API to compute the execution time for a piece of code in JavaScript. //capture the start time in a variable.var timeStart =;//run a time consuming task.for (counter = 0; counter //Do some processing var temp = temp + counter * counter;}//capture the current

Benchmarking the Speed of JavaScript/Angular Functions

See how to use the console’s time and timeend functions to capture time taken for a block of script to execute. See below for a simple example. //start the timerconsole.time(‘Start:Filter’);//the Filter code//console.timeEnd(‘End:Filter’);

Using JavaScript to Redirect to a New Page

When a person comes to a page, it is actually possible to redirect them to a new page. Because someone might have bookmarked the page, you can use this when you want to remove a page from your site so that you can avoid sending the person to a 404