npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yoastseo

v2.0.0-alpha.0

Published

Yoast client-side content analysis

Downloads

9,953

Readme

YoastSEO.js

Text analysis and assessment library in JavaScript. This library can generate interesting metrics about a text and assess these metrics to give you an assessment which can be used to improve the text.

Screenshot of the assessment of the given text

Also included is a preview of the Google search results which can be assessed using the library.

Documentation

Installation

You can install YoastSEO.js using npm:

npm install yoastseo

Or using yarn:

yarn add yoastseo

Usage

You can either use YoastSEO.js using the web worker API or use the internal components directly.

Because a web worker must be a separate script in the browser you first need to create a script for inside the web worker:

import { AnalysisWebWorker } from "yoastseo";

const worker = new AnalysisWebWorker( self );
worker.register();

Then in a different script you have the following code:

import { AnalysisWorkerWrapper, createWorker, Paper } from "yoastseo";

// `url` needs to be the full URL to the script for the browser to know where to load the worker script from.
// This should be the script created by the previous code-snippet.
const url = "https://my-site-url.com/path-to-webworker-script.js"

const worker = new AnalysisWorkerWrapper( createWorker( url ) );

worker.initialize( {
    locale: "en_US",
    contentAnalysisActive: true,
    keywordAnalysisActive: true,
    logLevel: "ERROR",
} ).then( () => {
    // The worker has been configured, we can now analyze a Paper.
    const paper = new Paper( "Text to analyze", {
        keyword: "analyze",
    } );

    return worker.analyze( paper );
} ).then( ( results ) => {
    console.log( 'Analysis results:' );
    console.log( results );
} ).catch( ( error ) => {
    console.error( 'An error occured while analyzing the text:' );
    console.error( error );
} );

Usage of internal components

If you want to have a more bare-bones API, or are in an environment without access to Web Worker you can use the internal objects:

import { AbstractResearcher, Paper } from "yoastseo";

const paper = new Paper( "Text to analyze", {
    keyword: "analyze",
} );
const researcher = new AbstractResearcher( paper );

console.log( researcher.getResearch( "wordCountInText" ) );

Note: This is currently a synchronous API, but will become an asynchronous API in the future.

Supported languages

SEO analysis

Function word support, which is used for internal linking, insights, and keyphrase-related analysis, is available in the following languages:

English, German, Dutch, French, Spanish, Italian, Portuguese, Russian, Polish, Swedish, Hungarian, Indonesian, Arabic, Hebrew, Farsi, Turkish, Norwegian, Czech, Slovak, Greek, Japanese

Readability analysis

| Language | Transition words | Flesch reading ease | Passive voice | Sentence beginnings | Sentence length1 | |------------ |------------------ |--------------------- |--------------- |--------------------- |----------------------------- | | English | ✅ | ✅ | ✅ | ✅ | ✅ | | German | ✅ | ✅ | ✅ | ✅ | ✅ | | Dutch | ✅ | ✅ | ✅ | ✅ | ✅ | | French | ✅ | ✅ | ✅ | ✅ | ✅ | | Spanish | ✅ | ✅ | ✅ | ✅ | ✅ | | Italian | ✅ | ✅ | ✅ | ✅ | ✅ | | Portuguese | ✅ | ✅ | ✅ | ✅ | ✅ | | Russian | ✅ | ✅ | ✅ | ✅ | ✅ | | Catalan | ✅ | ❌3 | ❌3 | ❌3 | ❌3 | | Polish | ✅ | ❌2 | ✅ | ✅ | ✅ | | Swedish | ✅ | ❌2 | ✅ | ✅ | ✅ | | Hungarian | ✅ | ❌2 | ✅ | ✅ | ✅ | | Indonesian | ✅ | ❌2 | ✅ | ✅ | ✅ | | Arabic | ✅ | ❌2 | ✅ | ✅ | ✅ | | Hebrew | ✅ | ❌2 | ✅ | ✅ | ✅ | | Farsi | ✅ | ❌2 | ✅ | ✅ | ✅ | | Turkish | ✅ | ❌2 | ✅ | ✅ | ✅ | | Norwegian | ✅ | ❌2 | ✅ | ✅ | ✅ | | Czech | ✅ | ❌2 | ✅ | ✅ | ✅ | | Slovak | ✅ | ❌2 | ✅ | ✅ | ✅ | | Greek | ✅ | ❌2 | ✅ | ✅ | ✅ | | Japanese | ✅ | ❌2 | ❌4 | ✅ | ✅ |

1 This means the default upper limit of 20 words has been verified for this language, or the upper limit has been changed.

2 There is no existing Flesch reading ease formula for these languages.

3 This means that the functionality for this assessment is currently not available for these languages.

4 The Passive voice check for Japanese is not implemented since the structure is the same as the potential form and can additionally be used for an honorific purpose. Identifying whether a verb is in its passive, honorific or potential form is problematic without contextual information.

The following readability assessments are available for all languages:

  • sentence length (with a default upper limit of 20 words, see1 above )
  • paragraph length
  • subheading distribution
  • text presence

Inclusive language analysis

The inclusive language analysis is currently available in English.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

npm test

Or using yarn:

yarn test

Generate coverage using the --coverage flag.

Code style

To test your code style:

yarn lint

Testing with Yoast SEO

In the YoastSEO.js directory, run:

npm link

Or using yarn:

yarn link

Then, in the project directory where you want to test the package, assuming you have a complete development version, run:

npm link yoastseo

Or using yarn:

yarn link yoastseo

If you want to unlink, simply do:

npm unlink yoastseo

Or using yarn:

yarn unlink yoastseo

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security [at] yoast.com instead of using the issue tracker.

Credits

License

We follow the GPL. Please see License file for more information.