fetch

  • function
steal.hooks.fetch  

A loader hook that fetches a module, usually from an http url, returning the source of that module.

fetch(load)

Parameters

  1. load {load}

    The load object associated with this module.

The fetch is used to retrieve a module's source, so that it can be passed on to the next loader hook translate.

Here's an example of a loader override that stores module source in localStorage:

var oldFetch = loader.fetch;

loader.fetch = function(load) {
    if(localStorage[load.name]) {
        return localStorage[load.name];
    }

    return oldFetch.call(this, load).then(function(source){
        localStorage[load.name] = source;

        return source;
    });
};
Help us improve StealJS by taking our community survey