Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ebay-predict

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ebay-predict

A component to prefetch static assets from a prediction service

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ebay-predict Build Status

ebay-predict is a simple tag to prefetch static assets from a prediction service. A prediction service is a server endpoint, that responds with the suggested JSON schema (see below). If the service is not hosted on the same origin as the page, please ensure proper CORS support is enabled. <ebay-predict> triggers the prefetch only after the page load event and use the requestIdleCallback API, to ensure the current page is rendered without any interferance. If requestIdleCallback API is not available, then the provided delay is used.

Usage

  1. Install and save the module
npm install ebay-predict --save
  1. Add dependency in your page browser.json
"ebay-predict/browser.json"
  1. The module exposes a tag <ebay-predict>. This can be embeded in the <footer> tag of page HTML
<html>
...
<footer>
    <ebay-predict src="https://www.ebay.com/sch/predict" delay="200" limit="2"/> 
</footer>
</html>

<ebay-predict> Attributes

NameTypeStatefulDescription
srcStringNoprediction service endpoint (mandatory)
delayStringNoOnly used when requestIdleCallback API is not available. A delay in milliseconds for the prefetch to trgger, after the page load event (default: "200")
limitStringNoa limit on the number of resources (for each type) to be prefetched. Use caution when prefetching more than 2 resources, as that may contend with current page bandwidth (default: "2")

Server response

Prediction service JSON schema and sample response

JSON Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "css": {
      "type": "array",
      "items": [
        {
          "type": "string"
        },
        {
          "type": "string"
        }
      ]
    },
    "js": {
      "type": "array",
      "items": [
        {
          "type": "string"
        },
        {
          "type": "string"
        }
      ]
    },
    "media": {
      "type": "array",
      "items": [
        {
          "type": "string"
        },
        {
          "type": "string"
        }
      ]
    }
  }
}

Sample response

{
    "css": ["https://ir.ebaystatic.com/rs/c/br/inception-PMg1-OXo.css", "https://ir.ebaystatic.com/rs/c/br/highlnfe-BTZUdVe3.css"],
    "js": ["https://ir.ebaystatic.com/rs/c/br/inception-dnRHPO-V.js", "https://ir.ebaystatic.com/rs/c/br/highlnfe-AK2d_fr4.js"],
    "media": ["https://i.ebayimg.com/00/s/MzZYNDI=/z/BGEAAOSw8FRZqY4x/$_57.PNG", "https://i.ebayimg.com/images/g/aYoAAOSwl89cAW9D/s-l500.webp"]
}

Browser support

  • Chrome (desktop & Android)
  • Firefox
  • Opera
  • Safari (desktop & iOS)
  • IE8+
  • Android WebKit

Issues

Have a bug or a feature request? Please open a new issue

Maintainers

Contribute

Pull Requests welcome. Please submit Github issues for any feature enhancements, bugs or documentation problems.

License

Copyright (c) 2018 eBay Inc.

Released under the MIT License

FAQs

Package last updated on 02 Jan 2019

Did you know?

Socket

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.

Install

Related posts

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