@@ -571,33 +571,54 @@ from pyscript import sync
571
571
sync .hello (" PyScript" )
572
572
` ` `
573
573
574
- ### ` pyscript .py_modules `
574
+ ### ` pyscript .py_import `
575
575
576
576
!!! warning
577
577
578
578
**This is an experimental feature.**
579
579
580
580
Feedback and bug reports are welcome!
581
581
582
- If you have a lot of packages referenced in your configuration, startup
582
+ If you have a lot of Python packages referenced in your configuration, startup
583
583
performance may be degraded as these are downloaded.
584
584
585
- If a package is only needed under certain circumstances, we provide an
585
+ If a Python package is only needed under certain circumstances, we provide an
586
586
asynchronous way to import packages that were not originally referenced in your
587
587
configuration.
588
588
589
- ` ` ` html title= " a pyscript.py_modules example"
589
+ ` ` ` html title= " A pyscript.py_import example. "
590
590
< script type= " py" async >
591
- from pyscript import py_modules
591
+ from pyscript import py_import
592
592
593
- matplotlib, regex, = await py_modules (" matplotlib" , " regex" )
593
+ matplotlib, regex, = await py_import (" matplotlib" , " regex" )
594
594
595
595
print (matplotlib, regex)
596
596
</script >
597
597
```
598
598
599
- The ` py_modules ` call returns an asynchronous tuple containing the modules
600
- referenced as string arguments.
599
+ The ` py_import ` call returns an asynchronous tuple containing the Python
600
+ modules provided by the packages referenced as string arguments.
601
+
602
+ ### ` pyscript.js_import `
603
+
604
+ If you have a lot of JavaScript modules referenced in your configuration,
605
+ startup performance may be degraded as these are downloaded.
606
+
607
+ If a JavaScript module is only needed under certain circumstances, we provide
608
+ an asynchronous way to import packages that were not originally referenced in
609
+ your configuration.
610
+
611
+ ``` html title="A pyscript.js_import example."
612
+ <script type =" py" async >
613
+ from pyscript import js_import, window
614
+
615
+ escaper, = await js_import (" https://esm.run/html-escaper" )
616
+
617
+ window .console .log (escaper)
618
+ ` ` `
619
+
620
+ The ` js_import` call returns an asynchronous tuple containing the JavaScript
621
+ modules referenced as string arguments.
601
622
602
623
## HTML attributes
603
624
0 commit comments