1. Recipes
  2. Seperate Desktop Logic from Web App Logic

Recipes

Seperate Desktop Logic from Web App Logic

If you only have a small amount of desktop-specific code then it is fine to keep that functionality in the same file as your web app's javascript. However, if you have a lot of desktop-specific code then we recommend separating all of your desktop specific logic into a separate javascript file. This will ensure that the javascript for your web app is as small as possible.

You can add your desktop-specific javascript into a separate file and import it when your app is being run as a desktop app. Here's a simple way to do this:

        <script type="module">
  if (window.todesktop) {
    import('some-module.mjs');
  }
</script>