Preload keyboards for a keymanweb

Hello. I need some assistance regarding keymanweb keyboard.
I want to use several languages in my application. Currently when I select a new language it takes some time till new keyboard is loaded and displayed.
Is it possible to preload specific keyboards when page is loaded the first time?
Thanks in advance !

That depends on how you’re using KeymanWeb. Our main reference for different ways to link keyboards can be found here: https://help.keyman.com/developer/engine/web/12.0/guide/adding-keyboards

Directly linking a keyboard (the first section) results in a more responsive user experience than when querying our CDN. It will still take a bit of time for the keyboard to show, but by hosting the keyboard directly on your site, this eliminates the need to query our server, wait for a response, and only then start loading the keyboard. This does come with a tradeoff; it then becomes your responsibility to ensure the keyboards you use remain sufficiently up-to-date.

The key thing to note here - this provides us with a known location for the keyboard’s source.

If that isn’t responsive enough, there’s one more trick you can implement. While I believe the bit about a “loader script” is outdated at this point, as long as you link the keyboard script files (directly, no “_load” variant) themselves after KeymanWeb’s source files, this will allow your keyboards to be preloaded as soon as KeymanWeb completes initialization. This has been supported since at least version 10.0. Note that you’ll need to directly link a source URL within the page; hosting the files yourself for the keyboards you want is the easiest way to do this.


We don’t yet support an API function (on KeymanWeb itself) that allows preloading keyboards whose info is retrieved from API calls against our CDN. That said, it should be possible to do if your site has a PHP (or other, similar server-side processing) backend if you’re willing to do a little coding work.

If this approach for keyboard preloading interests you, you will likely find https://help.keyman.com/developer/cloud/4.0/ to be a useful reference. The JSON returned by the calls detailed on that page will provide you with direct links to the compiled keyboards, which PHP (or similar) could then directly link as if the keyboards had been locally-hosted, as detailed above the ‘break’. This may cause your server to deliver the page a bit more slowly if you don’t employ caching, as it would take responsibility for the CDN calls, but this would allow the page itself to be more responsive as a result.

Thank you very much @joshua_horton for a quick response and support. I think only that case I can use according to specific of my code.
" If that isn’t responsive enough, there’s one more trick you can implement. While I believe the bit about a “loader script” is outdated at this point, as long as you link the keyboard script files (directly, no “_load” variant) themselves after KeymanWeb’s source files, this will allow your keyboards to be preloaded as soon as KeymanWeb completes initialization. This has been supported since at least version 10.0. Note that you’ll need to directly link a source URL within the page; hosting the files yourself for the keyboards you want is the easiest way to do this."
I have saved locally the sourcefiles and the keyboards. Do I need to do the following in my html page:

  1. add script tag with source to the keyman web
  2. add script tags with links to different keyboards language files (that I use in my application)
  3. Do stuff with kmw.addKeyboards(…);
    And this will be enough for the different keyboards to be preloaded. Is it correct?

That is correct. You do still need to call kmw.addKeyboards(...) with the “stub” information, even when using <script> tags to directly link the keyboards.

1 Like