Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 0.1.1 to 0.1.2

2

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

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

@@ -0,1 +1,6 @@

/**
* Copyright (c) 2015 Joe Podwys
* Copyright (c) 2014-2015 Alexandre Dieulot (For segments taken from InstantClick.js)
*/
(function (root, factory) {

@@ -18,2 +23,3 @@ if (typeof exports === 'object') module.exports = factory();

self.addContainers(config.containers);
return self;
}

@@ -87,7 +93,5 @@

function isExcluded(a){
if(self.$exclusions.length){
for(var i = 0; i < self.$exclusions.length; ++i){
if(a.href.indexOf(self.$exclusions[i]) > -1){
return true;
}
for(var i = 0; i < self.$exclusions.length; ++i){
if(a.href.indexOf(self.$exclusions[i]) > -1){
return true;
}

@@ -109,13 +113,19 @@ }

function createLinkTag(url){
var link = document.createElement('link');
link.setAttribute('rel', 'prefetch');
link.setAttribute('href', url);
return link;
}
function injectPrefetchLink(a){
if(a && isPrefetchable(a)){
var url = (typeof a === 'object') ? a.href : a;
var link = document.createElement('link');
link.setAttribute('rel', 'prefetch');
link.setAttribute('href', url);
if(!a) return;
var url = (typeof a === 'object') ? a.href : a;
var link = (url) ? createLinkTag(url) : null;
if(link){
document.getElementsByTagName('head')[0].appendChild(link);
if(typeof a === 'object'){
a.setAttribute('data-no-prefetch', '');
}
}
if(typeof a === 'object'){
a.setAttribute('data-no-prefetch', '');
}
}

@@ -130,5 +140,3 @@

function mousedown(e){
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)){
return;
}
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)) return;
var a = getLinkTarget(e.target);

@@ -139,5 +147,3 @@ injectPrefetchLink(a);

function mouseover(e){
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)){
return;
}
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)) return;
var a = getLinkTarget(e.target);

@@ -176,3 +182,3 @@ if(a && isPrefetchable(a)){

return new Prefetch();
return new Prefetch().init();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc