@@ -105,23 +105,44 @@ Distributing Javascript Components
105105
106106There are two ways that you can distribute your :ref: `Custom Javascript Components `:
107107
108- - In a Python package via PyPI _
109108- Using a CDN _
109+ - In a Python package via PyPI _
110+
111+ These options are not mutually exclusive though, and it may be beneficial to support
112+ both options. For example, if you upload your Javascript components to NPM _ and also
113+ bundle your Javascript inside a Python package, in principle your users can determine
114+ which work best for them. Regardless though, either you or, if you give then the choice,
115+ your users, will have to consider the tradeoffs of either approach.
116+
117+ - :ref: `Distributing Javascript via CDN_ ` - Most useful in production-grade applications
118+ where its assumed the user has a network connection. In this scenario a CDN's `edge
119+ network <https://en.wikipedia.org/wiki/Edge_computing> `__ can be used to bring the
120+ Javascript source closer to the user in order to reduce page load times.
121+
122+ - :ref: `Distributing Javascript via PyPI_ ` - This method is ideal for local usage since
123+ the user can server all the Javascript components they depend on from their computer
124+ without requiring a network connection.
125+
126+
127+ Distributing Javascript via CDN _
128+ ................................
110129
111- These options are not mutually exclusive though - if you upload your Javascript
112- components to NPM _ and also bundle your Javascript inside a Python package, in principle
113- your users can determine which option work best for them. Regardless though, either you
114- or, if you give then the choice, your users, will have to consider the tradeoffs of
115- either approach .
130+ Under this approach, to simplify these instructions, we're going to ignore the problem
131+ of distributing the Javascript since that must be handled by your CDN. For open source
132+ or personal projects, a CDN like https://unpkg.com/ makes things easy by automatically
133+ preparing any package that's been uploaded to NPM _. If you need to roll with your own
134+ private CDN, this will likely be more complicated .
116135
117- - Distribution via PyPI _ - This method is ideal for local usage since the user can
118- server all the Javascript components they depend on from their computer without
119- requiring a network connection.
136+ In either case though, on the Python side, things are quite simple. You need only pass
137+ the URL where your package can be found to :func: ` ~idom.web.module.module_from_file `
138+ where you can then load any of its exports:
120139
121- - Distribution via a CDN _ - Most useful in production-grade applications where its assumed
122- the user has a network connection. In this scenario a CDN's
123- `edge network <https://en.wikipedia.org/wiki/Edge_computing >`__ can be used to bring
124- the Javascript source closer to the user in order to reduce page load times.
140+ .. code-block ::
141+
142+ import idom
143+
144+ your_module = ido.web.module_from_file("https://some.cdn/your-module")
145+ YourComponent = idom.web.export(your_module, "YourComponent")
125146
126147
127148 Distributing Javascript via PyPI _
@@ -367,12 +388,6 @@ creating your custom components using the provided `template repository`_ so you
367388up and running as quickly as possible.
368389
369390
370- Distributing Javascript via CDN _
371- ................................
372-
373- Under construction...
374-
375-
376391.. Links
377392.. =====
378393
0 commit comments