Following this answer I try to add an external JS file named Pym.js to my Magento 2.3 shop.
I've tried several things but can not get it to work. My current setup it:
app/design/frontend/vendor/theme/requirejs-config.js
var config = {
"paths": {
"pym": "https://pym.nprapps.org/pym.v1"
}
};
app/design/frontend/vendor/theme/Magento_Theme/default_head_blocks.xml
<page xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="pym_child" template="Magento_Theme::js/pym_child.phtml"/>
</referenceContainer>
</page>
app/design/frontend/vendor/theme/Magento_Theme/templates/js/pym_child.phtml
<script type="text/javascript">
require([
"pym"
], function () {
var pymChild = new pym.Child();
});
</script>
The error I keep getting is
Uncaught ReferenceError: pym is not defined at Object.execCb (require.js:1650) at Module.check (require.js:866) at Module. (require.js:1113) at require.js:132 at require.js:1156 at each (require.js:57) at Module.emit (require.js:1155) at Module.check (require.js:917) at Module.enable (require.js:1143)