Reference

Peer-to-peer

GretaOptions = {
  p2p: {
    enable: true,
    mode: 'performance'
  }
}
enable

boolean, to turn peer-to-peer on and off

  • default: true
mode

string, sets the routing algorithm.

  • default: 'performance'
  • 'performance' optimizes for end user experience
  • 'offload' focuses on offloading servers with peer-to-peer network

Cache

GretaOptions = {
  cache: {
    version: 1,
    time: 31536000000 // 365 * 24 * 3600 * 1000
  }
}
version

integer, increment it by 1 to bust all users’ browser cache

  • default: 1
time

integer, cache time to live in milliseconds.

  • default: 31536000000, one year
  • recommended to set it as long as possible and then use `version` to purge all browsers within milliseconds

Lazy loading

GretaOptions = {
  lazyLoad: {
    offset: 2,
    addClassOnLoad: '',
    imgAttribute: 'data-src',
    bgImgAttribute: 'data-bg-src'
  }
}
offset

float, sets scale for the lazy loading observer, as a factor of screen height.

  • default: 2, means viewing scope is set to 2 times the screen height.
  • recommended value: between 1 and 2.
  • Smallest acceptable value: 1. Values smaller than 1 will be replaced with 1.
addClassOnLoad

string, the name of the css class to append when image is loaded.

  • default: not set
imgAttribute

string, the name of the attribute holding the url to the asset on lazy loading the image.

  • default: 'data-src'
bgImgAttribute

string, the name of the attribute holding the url to the asset on lazy loading the background image.

  • default: 'data-bg-src'