mozilla
Your Search Results

    Packaged or hosted?

    While Packaged Apps are the recommended way to deliver your Firefox Marketplace apps, there may be benefits to using the Hosted App approach. This page provides a guide to the key differences between these delivery methods and offers advice on choosing between the two.

    The primary difference between Packaged Apps and Hosted Apps is fairly obvious: the former delivers all its content onto a user’s device, while the latter delivers the app‘s assets on demand from a web server. However, there are many more subtle differences that you should consider when choosing between the two.

    Packaged and Hosted apps compared

    Let’s start by looking at key features of Packaged Apps and Hosted Apps and see how they differ.

    Functionality

    The overriding reason for creating a Packaged App is the functionality it can offer to your users. Packaged Apps can use the Privileged APIs, which provide apps with the ability to integrate closely with hardware and software features on a Firefox OS device. If, for example, your app wanted to allow the user to select and use details of contacts stored on the device, this can only be done in a Packaged App.

    Feature Packaged Apps Hosted Apps
    API support All available Firefox OS APIs No access to Privileged and Internal (Certified) APIs
    Device integration Excellent (see API support) Limited
    Can access web resources Yes Yes
    In-app purchases Yes (but requires own server too) Yes

    Performance

    In general you should expect users to observe better response from Packaged Apps, as all the app’s assets are stored locally on their device. When accessing remote data from the Internet, generally there’ll be no significant difference between the two options.

    Feature Packaged Apps Hosted Apps
    Start-up time Fast, all assets on the device Network limited, all assets downloaded
    Network impact Remote data only App content (unless AppCached) and remote data
    Content optimization, e.g. screen size Through redundant assets or multiple packages On-the-fly
    Impact of data plan limits Low High

    Availability

    While Firefox OS supports AppCache and local data storage, Packaged Apps provide the app’s assets locally by default, removing the need to explicitly design for application caching.

    Feature Packaged Apps Hosted Apps
    Offline support By default for packaged assets, support for online data needs to be specifically added. Needs to be specifically added for all app resources.
    Availability constraints Device battery and network availability (if applicable) Server uptime, device battery and network availability (if applicable)
    Supported on Android Yes (APIs limited) Yes (APIs limited)
    Supported on Desktops Yes (APIs limited) Yes (APIs limited)
    Runs on any browser No, Firefox specific Yes, unless Firefox specific APIs used

    Hosting

    The cost and effort of hosting a server to deliver Hosted Apps may be an issue for you, if it is then Packaged Apps have a clear advantage.

    Feature Packaged Apps Hosted Apps
    Server required No Yes

    Discovery

    In most cases you’ll want your web app to be easily discoverable by user’s worldwide. For most apps you’ll achieve this through the Firefox Marketplace, however, Hosted Apps offer some additional possibilities.

    Feature Packaged Apps Hosted Apps
    Discovery Through Marketplace Through Marketplace and own site
    Direct access using a URL No Yes

    Delivery

    All apps need to be delivered to a user’s device, which will be affected by both the network bandwidth and the available storage memory on the device. Here the overall size of your app’s assets will be the primary decision driver, the larger your app the more likely you’ll want to deliver it as a Hosted App.

    Feature Packaged Apps Hosted Apps
    Marketplace review time Longer (when using Privileged APIs) Shorter
    Self-publication Yes Yes
    App updates Requires a new package to be loaded onto Marketplace Core app changes delivered on-the-fly, new install details (e.g. name, icon) require a new Marketplace package
    App Asset/Content redundancy on device Possible No, only used assets/content downloaded
    App asset limits Practical package size limit is device memory and network dependent, generally < 50Mb, <5Mb for low memory devices Online: No practical limit
    AppCached: As for Packaged Apps
    Number of apps per device Limited by device memory Online: Practically unlimited
    AppCached: As for Packaged Apps
    Asset extendibility Limited, except for data from XMLHttpRequest and browser links all assets must be on the device Unlimited, within Origin
    Remote content By using iframes, but that content will not have access to privileged APIs nor will it have the default CSP applied to it. By default

    Development

    While there are no significant development issues to consider in choosing between Packaged Apps and Hosted apps there are some differences, which if nothing else, are helpful to be aware of before you start coding.

    Feature Packaged Apps Hosted Apps
    Delivery standard Proprietary (albeit a simple ZIP) Web standard
    Debugging Easier, no Origin limitations Harder for older versions; Firefox OS older than 2.1 and Firefox Desktop/Android older than 34 have a limit of one app per Origin
    Reading JavaScript assets Requires use of XMLHttpRequest Direct
    Coding challenges OAuth functionality for Facebook, Dropbox, Twitter, etc.  
    Manifest must specify a launch_path Required Optional
    Apps per Origin Doesn’t apply Doesn't apply; one for Firefox OS before 2.1 and Firefox Desktop/Android before 34.
    CSP Enforced Optional
    mozApps API install function Apps.installPackage apps.install

    Making your choice

    The choice of Packaged App or Hosted App isn’t necessarily a simple one. There are however a few key factors that can be used to determine the option to use, as shown in this flowchart :

    To further assist you, here are some examples:

    1. A small offline game, such as tic-tac-toe, is well suited to a Packaged App.
    2. A large online game would be better suited to a Hosted App.
    3. An app that needs to provide alarms to the user would need to be a Packaged App, as Privileged APIs will be used.

    Document Tags and Contributors

    Contributors to this page: SphinxKnight, chrisdavidmills, trevorh, rebloor
    Last updated by: chrisdavidmills,