🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

prefetch

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefetch - npm Package Compare versions

Comparing version

to
0.2.1

2

package.json
{
"name": "prefetch",
"version": "0.2.0",
"version": "0.2.1",
"description": "Customizable interaction-based link prefetching.",

@@ -5,0 +5,0 @@ "main": "prefetch.js",

@@ -141,3 +141,5 @@ /**

var a = getLinkTarget(e.target);
execute(a);
if(a && isPrefetchable(a)){
execute(a);
}
}

@@ -148,3 +150,5 @@

var a = getLinkTarget(e.target);
execute(a);
if(a && isPrefetchable(a)){
execute(a);
}
}

@@ -151,0 +155,0 @@

@@ -104,9 +104,9 @@ # prefetch

The `callback` param must be a function and it accepts up to three parameters. In the exampmle below, the callback function evaluates the href's URL and, based on the presence of some identifier, decides whether to execute an ajax call or procede with the normal `prefetch` behavior.
The `callback` param must be a function and it accepts up to three parameters. In the example below, the callback function evaluates the href's URL and, based on the presence of some identifier, decides whether to execute an ajax call or procede with the normal `prefetch` behavior.
```javascript
function handlePrefetch(url, anchor, fetch){
function handlePrefetch(url, anchor, injectPrefetchLink){
//url: the string from the href attribute of the anchor tag over which the user's cursor hovered
//anchor: the <a> tag over which the user's cursor hovered
//fetch: the function that prefetch internally executes to inject a prefetch link
//injectPrefetchLink: the function that prefetch internally executes to inject a prefetch link

@@ -116,5 +116,5 @@ if(url.indexOf('some-identifier') > 0){

} else {
fetch(url);
injectPrefetchLink(url);
}
}
```