mmig/libflac.js

Which library variants require asynchronous initialization?

Closed this issue · 2 comments

All samples contain this placeholder comment:

//NOTE if async-library variant is used, should wait for initialization:
//Flac.onready(function(){ ...

In the documentation, the chapter "Async Initialization" states that "Some variants of the libflac.js library are loaded asynchronously". But I can't find the information which variants these are exactly.

Which variants require asynchronous initialization, which don't?

generally, the asynchronous initialization is relevant for all library variants that have additional, required library files (i.e. in addition to the main JavaScript library file)

the section Library Variants (or specifically the sub-sections Default Library, Minified Library, and Development Library) lists the additional required files per variant:

in short:

  • all WASM variants, as well as the minified variant are loaded asynchronously
  • the asm.js variants for default and development are initialized synchronously

this may differ, if you are using a build-system like webpack and configure it to inline all the library code (which would result in synchronous initialization)

I would recommend to integrate the library as if it were initialized asynchronously, since the same code will also work if it is initialized synchronously (i.e. using one of the different on ready mechanism before accessing the library functionality, as described in the section Async Initialization that you mentioned)

Thanks for the clarification!