String Reversing Algorithm Performance In JavaScript

Wherever performance is the key factor, choosing the right algorithm, (in a very unbiased fashion,) is a very crucial factor. And generally for reversing string in JavaScript applications, I endorse this petite string reversal algorithm using Array.reverse() method.

Continue reading String Reversing Algorithm Performance In JavaScript

Load jQuery Plugins Only When Required (Runtime)

I have often observed that websites that are template-driven (like blogs, cms, etc), tend to load all the required scripts and css in every page. One such example would be WordPress blogs with plugins for various types of content processing (overlay, tooltip, animation, etc.) Every page of such a WordPress driven site loads the relevant plugin stylesheets and javascripts, even though it might not be required for that particular page.

Here is a jQuery code I wrote in order to load prettyPhoto jQuery plugin (prettyPhoto homepage) only when required. This process can also be applied to other plugins by analyzing the plugin triggers from within the rest of the page content.

Continue reading Load jQuery Plugins Only When Required (Runtime)

Optimizing JavaScript (part 1)

In my years of experience in programming, I have observed that certain performance ‘tweaks’ work best for certain languages. This is mostly due to the nature of the interpreter1/compiler2 involved in executing a particular piece of code.

Continue reading Optimizing JavaScript (part 1)

  1. Interpreters are programs that execute codes one line at a time. See: Interpreter  in Wikipedia []
  2. a program that decodes instructions written in a higher order language. See: Compiler in Wikipedia []