Simple jQuery Image Preloading

Again, this is more a note to myself, but I find the best function to preload images with jQuery is the following:

jQuery.preloadImages = function() {
     for(var i = 0; i<arguments.length; i++)
    {
          jQuery("<img>").attr("src", arguments[i]);
    }
}

This accepts X amount of arguments and can be called like the following:

$.preloadImages("/static/img/loadinganimation.gif", "/static/img/throbber.gif");

Why would you want to do this? Simple – if you’re using any “loading animations” on your site, with animated GIFs, you may find that on first activation on certain browsers the GIF is missing. If you preload it using a function like this one, your problem is solved.

Credit to this function goes to bloggingdeveloper.com.

0 Comments

Full UK Postcode Regular Expression Pattern (incl. London)

This is more a note to myself than anything, but I hope this can be a use of other developers looking to regex validate UK Postcodes. This validates all postcodes including London ones fine. (more…)

2 Comments

Multiple CodeIgniter databases e.g. MSSQL and MySQL

In a web app I’m developing at the moment, the primary database in use is an instance of Microsoft SQL Server 2005 Express. This works OK with the CodeIgniter/PHP front-end. Obviously, if I had the choice, I would be using MySQL but in the real world sometimes this isn’t possible. And MSSQL is working great with simultaneous connections from the PHP app and MS Access.

I hit a point where I also wanted to access a MySQL database as well. This is easier than you think to configure, and worked first time with me without any stress or hair pulling. (more…)

0 Comments

Simple Javascript pause/sleep functionality

One thing that I’ve seen lots of people ask questions about is how to reliably pause or sleep execution of Javascript code. There are a variety of solutions, however none seem to be reliable as Javascript cannot really handle this functionality, except if you use setTimeout, which is no good if you just want to not consider any events, and you just want a bog standard sleep like PHP has. (more…)

0 Comments

Extending Alen Grakalic’s EasySlider for mouseover pausing

EasySlider is an awesome quick and easy jQuery plugin to get things sliding with ease. I’ve used it on a clients site and found it very easy and versatile. There are plenty of options and customisations such as varying speed, pause length, repetition and so on.

There was one thing I noticed, however, that wasn’t customisable. A simple pause facility when someone hovers their cursor over the EasySlider object. I know from experience that putting something on a continuous loop is great to add a bit of movement to the page, but is no good if the user can’t stop it while they’re reading the content of the slide. (more…)

5 Comments