
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
intersection-observer-amd
Advanced tools
The original, official W3C IntersectionObserver Polyfill, served in AMD.
Because with AMD you can load the IntersectionObserver
only where it's needed, as dependency of another script, e.g. vanilla lazyload.
Insert Require.JS's script (or another AMD module loader) in your page.
<script src="https://cdn.jsdelivr.net/npm/requirejs@2.3.6/bin/r.min.js"></script>
In your script, create a dependencies array.
For example, if you need IntersectionObserver
polyfill and vanilla-lazyload, do like that:
var dependencies = [
"IntersectionObserver" in window
? null
: "https://cdn.jsdelivr.net/npm/intersection-observer-amd@2.0.0/intersection-observer.amd.min.js",
"https://cdn.jsdelivr.net/npm/vanilla-lazyload@11.0.5/dist/lazyload.amd.min.js"
];
Finally, use require to execute your script, having the dependecies loaded in the right order and ready to use.
// _ is always null, since the polyfill is attached to the window object
require(dependencies, function(_, LazyLoad) {
window.ll = new LazyLoad({
elements_selector: ".lazy",
// More options?
});
});
To update this in case the guys at W3C improve their polyfill:
rollup --format=amd --output=intersection-observer.amd.js -- intersection-observer.js
FAQs
A polyfill for IntersectionObserver, served as AMD
We found that intersection-observer-amd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.