Initialization options

WProofreader can be initialized in several ways depending on your integration scenario. This page explains the supported methods and shows how to apply them in practice.

The WEBSPELLCHECKER_CONFIG (referred to as CONFIG) can be defined in a script or loaded from a file as described in the SDK overview.

circle-info

Once initialized, you can further adjust behavior and UI using the configuration referencearrow-up-right.

👉 See demosarrow-up-right for working examples with different editors and HTML elements.


Initialize using autoSearch

The autoSearch feature detects new editable fields on the page and enables proofreading when the field is focused.

  • Useful for pages with multiple controls.

  • Improves performance by checking only the active field.

  • Frees memory when fields are removed or hidden, preventing leaks.

  • Proofreading starts only when a field receives focus.

Example: using CONFIG

<script>
  window.WEBSPELLCHECKER_CONFIG = {
    autoSearch: true,
    lang: 'en_US',
    ...
  };
</script>

Example: using inline data attributes

circle-exclamation

Initialize using init() method

Use init() when you want explicit control over where WProofreader is enabled.

  • Suitable for static pages where controls are known in advance.

  • Instances are created on page load.

  • With dynamic content, you must manage when to create or destroy instances.

  • Proofreading is enabled immediately. It doesn’t require focus or selection, unlike with autoSearch.

Example: single HTML element

Example: multiple elements

For multiple fields (such as a div and a textarea), define CONFIG once and call init() for each target element.

👉 See the demo for HTML controlsarrow-up-right.

Example: rich text editors

For editors such as CKEditor 4, Froala, or Quill, initialization usually combines autoSearch, autoDestroy, and init():

  • init() ensures WProofreader is explicitly attached to the editor’s editable container.

  • autoSearch restores the instance dynamically (for example, when switching between editing modes).

  • autoDestroy removes the instance when the editable container is deleted or hidden, preventing memory leaks.

circle-check

👉 See the demo with CKEditor 4arrow-up-right, Froalaarrow-up-right, or Quillarrow-up-right.


Initialize using data-wsc-autocreate

Mark elements with data-wsc-autocreate="true" to create instances automatically. Element-level attributes can override global CONFIG settings.

Example: HTML elements

circle-info

In this example, the textarea uses Spanish (es_ES) because element attributes override the global lang setting.


Last updated

Was this helpful?