How to use webcoach - 7 common examples

To help you get started, we’ve selected a few webcoach 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 / lib / plugins / browsertime / index.js View on Github external
'The coach got the following errors: ' +
                      JSON.stringify(coachAdvice.errors),
                    {
                      url,
                      runIndex,
                      iteration: runIndex + 1
                    }
                  )
                );
              }

              let advice = coachAdvice;
              // If we run without HAR
              if (result.har) {
                // make sure to get the right run in the HAR
                const myHar = api.pickAPage(result.har, harIndex);
                const harResult = await api.runHarAdvice(myHar);
                advice = api.merge(coachAdvice, harResult);
              }
              queue.postMessage(
                make('coach.run', advice, {
                  url,
                  group,
                  runIndex,
                  iteration: runIndex + 1
                })
              );
            }

            aggregator.addToAggregate(run, group);
            runIndex++;
          }
github sitespeedio / sitespeed.io / lib / plugins / browsertime / index.js View on Github external
`${
                        options.resultDir
                      }/${this.resultUrls.relativeSummaryPageUrl(url)}`,
                      this.allOptions,
                      `${base}data/filmstrip/${runIndex + 1}/`
                    );
                  }
                }
              } else {
                log.error(
                  'Could not find the right index %s for har for url %s ',
                  harIndex,
                  url
                );
              }
              run.har = api.pickAPage(result.har, harIndex);
            }

            // Hack to get axe data. In the future we can make this more generic
            if (result[resultIndex].extras.length > 0) {
              if (result[resultIndex].extras[runIndex].axe) {
                const order = ['critical', 'serious', 'moderate', 'minor'];
                result[resultIndex].extras[runIndex].axe.violations.sort(
                  (a, b) => order.indexOf(a.impact) > order.indexOf(b.impact)
                );

                axeAggregatorPerURL.addStats(
                  result[resultIndex].extras[runIndex].axe
                );

                this.axeAggregatorTotal.addStats(
                  result[resultIndex].extras[runIndex].axe
github sitespeedio / sitespeed.io / lib / plugins / browsertime / index.js View on Github external
{
                      url,
                      runIndex,
                      iteration: runIndex + 1
                    }
                  )
                );
              }

              let advice = coachAdvice;
              // If we run without HAR
              if (result.har) {
                // make sure to get the right run in the HAR
                const myHar = api.pickAPage(result.har, harIndex);
                const harResult = await api.runHarAdvice(myHar);
                advice = api.merge(coachAdvice, harResult);
              }
              queue.postMessage(
                make('coach.run', advice, {
                  url,
                  group,
                  runIndex,
                  iteration: runIndex + 1
                })
              );
            }

            aggregator.addToAggregate(run, group);
            runIndex++;
          }

          // Let take the first runs timestamp and use that as the summary timestamp
github sitespeedio / sitespeed.io / lib / plugins / browsertime / index.js View on Github external
JSON.stringify(coachAdvice.errors),
                    {
                      url,
                      runIndex,
                      iteration: runIndex + 1
                    }
                  )
                );
              }

              let advice = coachAdvice;
              // If we run without HAR
              if (result.har) {
                // make sure to get the right run in the HAR
                const myHar = api.pickAPage(result.har, harIndex);
                const harResult = await api.runHarAdvice(myHar);
                advice = api.merge(coachAdvice, harResult);
              }
              queue.postMessage(
                make('coach.run', advice, {
                  url,
                  group,
                  runIndex,
                  iteration: runIndex + 1
                })
              );
            }

            aggregator.addToAggregate(run, group);
            runIndex++;
          }
github thomasjbradley / markbot / app / checks / performance / task.js View on Github external
ipcRenderer.on('__markbot-hidden-browser-perf-dom-advice-' + ipcListenerLabel, function (event, data) {
      var domAdvice = JSON.parse(data);

      ipcRenderer.removeAllListeners('__markbot-hidden-browser-perf-dom-advice-' + ipcListenerLabel);
      webLoader.destroy(win);
      win = null;

      webcoach.runHarAdvice(webcoach.pickAPage(har, 0), webcoach.getHarAdvice()).then(function (harAdvice) {
        const coachResults = webcoach.merge(domAdvice, harAdvice);
        const coachAdvice = coachResults.advice;
        let errors = [];
        let messages = [];
        let budgetDetails = generateBudgetReport(perf, coachAdvice);

        if (doesPassPerfBudget(perf, coachAdvice)) {
          messages.push(budgetDetails);
        } else {
          errors.push(budgetDetails);
        }

        markbotMain.debug(`Performance score: ${coachAdvice.score}`);

        Object.keys(coachAdvice.performance.adviceList).forEach(function (id) {
          let advice = coachAdvice.performance.adviceList[id];
github thomasjbradley / markbot / app / checks / performance / task.js View on Github external
webcoach.runHarAdvice(webcoach.pickAPage(har, 0), webcoach.getHarAdvice()).then(function (harAdvice) {
        const coachResults = webcoach.merge(domAdvice, harAdvice);
        const coachAdvice = coachResults.advice;
        let errors = [];
        let messages = [];
        let budgetDetails = generateBudgetReport(perf, coachAdvice);

        if (doesPassPerfBudget(perf, coachAdvice)) {
          messages.push(budgetDetails);
        } else {
          errors.push(budgetDetails);
        }

        markbotMain.debug(`Performance score: ${coachAdvice.score}`);

        Object.keys(coachAdvice.performance.adviceList).forEach(function (id) {
          let advice = coachAdvice.performance.adviceList[id];
          let error = `**${advice.title}** — ${advice.advice}`;
github sitespeedio / sitespeed.io / lib / plugins / browsertime / analyzer.js View on Github external
async function addCoachScripts(scripts) {
  const coachAdvice = await coach.getDomAdvice();
  scripts.coach = {
    coachAdvice: coachAdvice
  };
  return scripts;
}

webcoach

The coach gives you advice on building a better web page

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis