Deciding where to define grammars

Grammars for VoiceXML applications can be defined in an external file or inline, as explained in External and inline grammars. The only difference is the level of interaction between the VoiceXML browser and Web application server, and the resulting application performance. You will want to weigh such factors as:

For example, you might decide to define a grammar as an external file if the grammar is large and is in a menu or form that is unlikely to be executed. This design will minimize document access time.

Conversely, you might decide to define a grammar inline if you want it to be instantaneously ready, rather than having to download it from the Web application server, when the user accesses the menu or form. Alternatively, you might achieve similar results by fetching and caching the grammars when the application loads, as explained next.