Wednesday 21 August 2013

jquery Is vs hasClass

The is is multi-purpose, you can for example do is('.class')is(':checked'), etc which means ishas more to do where is hasClass is limited which only checks for a class being set or not.
Hence, hasClass should be faster if performance at any level is your priority.
You can always validate performance on this site as well over multiple browsers: jsperf.com ...These are some test cases to browse: jsperf.com/browse

Thursday 15 August 2013

Cache Memory


Cache memory (pronounced as “cash”) is placed between CPU and main memory. It is a semi-conductor memory consisting of static RAMs. It is a special and very high speed memory called a cache used to increase the speed of processing by making current program and data available to the CPU at a rapid rate.

It stores instruction, codes, and data, which are to be currently executed by the CPU. It is used to reduce the average access time for instruction and data, which are normally stored in the main memory. A cache memory also needs a cache controller for which cache controller ICs are available.

The technique of accessing a cache memory differs from that of main memory. It work according to ‘hit and miss’ on the matching of addresses from main memory to CPU and to it.

Cache memory is placed at two-three levels: first, second, and third level as L1, L2 and L3. Some microprocessor contains L1 and L2 and some contains L1, L2 and L3 within the microprocessor. Cache within the microprocessor is internal cache and outside the processor is external cache. So we can say cache memory in computer system is to compensate the speed difference between the main memory access time and processor logic. The use of cache memory lets the processor work in its actual speed.

Thursday 8 August 2013

Prevent double form submission in jquery

Function Debouncing with Underscore.js

Double submission in a form is the worst thing that can happen to you. Fortunately with the _.debounce() method it's easy to prevent it. What you have to do is set the third parameter of the debounce() method to true. This way, the function is triggered when you click the submit button but it won't be triggered again in case the submit button is clicked the second time in quick succession (double submission).
// prevent double click
$('button.my-button').on('click', _.debounce(function() {
    console.log('clicked')

    // code to handle form submition

}, 500, true)

Monday 5 August 2013

redirect website when javascript disable

  <noscript><meta http-equiv="Refresh" content="1;url=enablejavascript.html" /></noscript>