$.cacheFactory
✓ Published0🌍 Public
Aabernier
Last edited Sep 1, 2011
Created on Aug 13, 2011
This example demonstrates a reusable caching mechanism for asynchronous jQuery operations, specifically applied to script loading. It shows how the `$.cacheFactory` function wraps an arbitrary factory function—here, `$.cachedGetScript`—to memoize deferred promises keyed by URL. The code uses jQuery’s `$.Deferred`, `$.getScript`, and `.promise()` to ensure each script is fetched only once, while subsequent calls with the same URL receive the already-resolved promise and execute their callback immediately. The implementation relies on a plain JavaScript object as the cache store, with no external data source or rendering involved.
AI-generated description