This documentation site is about the unstable (upcoming) Comentario version.  Switch to the stable version »

Attribute: auto-init

The auto-init attribute of the <comentario-comments> tag controls Comentario load

The auto-init attribute of the comments tag controls whether the embedded Comentario comments will be rendered automatically upon page load.

Manual initialisation

If you disabled automatic initialisation by adding auto-init="false", you need to initialise Comentario manually by calling the main() method of the web component. Here’s a simple example:

<comentario-comments id="comments"></comentario-comments>
<script>
  window.onload = function() {
    document.getElementById('comments').main();
  };
</script>

Calling main() initialises Comentario. Repeated calls will re-initialise the web component, erasing and filling the comments from scratch.

Changing the value on-the-fly

This attribute is reactive, but — unlike the other attributes — it only has an effect as long as Comentario hasn’t been initialised yet. Setting it to any value other than false (or removing it altogether) then starts the widget up, which is an alternative to calling main():

document.querySelector('comentario-comments').setAttribute('auto-init', 'true');

Once Comentario is running, the attribute is no longer consulted: setting it to false will not tear the comments down.

See also