quicklink – Prefetch links (during idle time) based on what is in the user’s viewport

Great little piece of JavaScript which prefetches links, but only when the browser is idle (and when the user is on a “fast” connection). Uses the aforementioned Intersection Observer to detect which links are in-view.

Install it per NPM and call its quicklink(); method – for example after the DOM has loaded – to initialize the script.

Amongst ignore patterns, it’s also possible to define the origins which are allowed to be preloaded.

quicklink Source (GitHub) →

PxLoader, A JavaScript Preloader for HTML5 Apps

PxLoader is a Javascript library that helps you download images, sound files or anything else you need before you take a specific action on your site (like showing a user interface or starting a game). You can use it to create a preloader for HTML5 games and websites.

As used in Cut The Rope. Resulting code when used looks like:

// Create the loader and queue our 3 images. Images will not 
// begin downloading until we tell the loader to start. 
var loader = new PxLoader(), 
    backgroundImg = loader.addImage('images/headerbg.jpg'), 
    treesImg = loader.addImage('images/trees.png'), 
    ufoImg = loader.addImage('images/ufo.png'); 
// callback that will be run once images are ready 
loader.addCompletionListener(function() { 
    var canvas = document.getElementById('sample1-canvas'), 
        ctx = canvas.getContext('2d'); 
    ctx.drawImage(backgroundImg, 0, 0); 
    ctx.drawImage(treesImg, 0, 104); 
    ctx.drawImage(ufoImg, 360, 50); 
// begin downloading images 

PxLoader →