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

optimizely

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimizely

Runs optimizely experiments in node using either jsdom or cheerio + native node-vm

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-85.71%
Maintainers
2
Weekly downloads
 
Created
Source

Optimizely Build Status

Runs optimizely experiments in node using either jsdom (node-0.10 only, full-featured, resource-hungry) or cheerio+node-vm (0.10 and 0.12, simple, lightweight)

Install

npm install optimizely --save

Usage

  1. Load processing environment
// jsdom
var optimizely = require('optimizely')('jsdom');

// node vm
var optimizely = require('optimizely')('node_vm');

  1. Attach Optimizely code library
optimizely.setOptimizely(optimizelyCode);
  1. Process html page
// req - http request
// callback – return path out of this middleware

var originalHtml = getFinalHtmlBeforeResponse();

optimizely(req, originalHtml, function(err, modifiedHtml, extras)
{
  // only pass error if html isn't returned
  if (err && !html)
  {
    return callback(err);
  }

  // extras.images – array of image-src;
  // extras.cookies – cookie object;

  // return modified html
  callback(null, html);  
});

Notes

jQuery

In jsdom processor trimmed version of jQuery is used, which is provided by optimizely itself and bundled with the module. In turn node_vm processor is relying on augmented cheerio module.

Cookies

Module oven is used for cookie handling and it's cookie jar instance is returned in callback. Method extras.cookies.getCookieHeader() could be used to get cookie header formated string and extras.cookies.getCookies() to get list of cookie objects.

Images

Along with creating new cookies, optimizely adds images to track performed experiments, to make it slim and less opinionated, list of images passed to callback (extras.images) instead of modifying html in place.

TODO

  • More tests
  • Autoload of optimizely code

Keywords

FAQs

Package last updated on 21 May 2015

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