How to use the browsertime.Engine function in browsertime

To help you get started, we’ve selected a few browsertime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / bin / browsertimeWebPageReplay.js View on Github external
btOptions['view-port'] = '360x640';
    if (btOptions.browser === 'chrome') {
      const emulation = get(
        btOptions,
        'chrome.mobileEmulation.deviceName',
        'iPhone 6'
      );
      btOptions.chrome.mobileEmulation = {
        deviceName: emulation
      };
    } else {
      btOptions.userAgent = iphone6UserAgent;
    }
  }

  const engine = new browsertime.Engine(btOptions);
  const urls = getURLs(parsed.argv._);

  await testURLs(engine, urls);

  process.exit();
}
github sitespeedio / sitespeed.io / lib / plugins / browsertime / analyzer.js View on Github external
}
    const scriptCategories = await browserScripts.allScriptCategories;
    let scriptsByCategory = await browserScripts.getScriptsForCategories(
      scriptCategories
    );

    if (btOptions.script) {
      const userScripts = await parseUserScripts(btOptions.script);
      scriptsByCategory = merge(scriptsByCategory, userScripts);
    }

    if (btOptions.coach) {
      scriptsByCategory = addCoachScripts(scriptsByCategory);
    }
    scriptsByCategory = await addExtraScripts(scriptsByCategory, pluginScripts);
    const engine = new browsertime.Engine(btOptions);

    const asyncScript =
      pluginAsyncScripts.length > 0
        ? await setupAsynScripts(pluginAsyncScripts)
        : undefined;

    try {
      await engine.start();
      if (scriptOrMultiple) {
        const res = await engine.runMultiple(
          url,
          scriptsByCategory,
          asyncScript
        );
        return res;
      } else {
github sitespeedio / coach / lib / index.js View on Github external
async function runBrowsertime(url, script, options) {
  function browsertimeify(script) {
    return {
      coach: {
        domAdvice: script
      }
    };
  }

  browsertime.logging.configure(options);
  options.resultDir = process.cwd();

  const engine = new browsertime.Engine(options);
  const scripts = await browsertimeify(script);
  await engine.start();
  try {
    return engine.run(url, scripts);
  } finally {
    engine.stop();
  }
}

browsertime

Get performance metrics from your web page using Browsertime.

Apache-2.0
Latest version published 1 day ago

Package Health Score

81 / 100
Full package analysis

Similar packages