html-modules-toolkit
html-modules-toolkit copied to clipboard
Script tag with html module?
The example shows a html module in a script tag: https://github.com/PolymerLabs/html-modules-toolkit/blob/master/examples/common/src/index.html
Is there no limitation to what data can be represented by a script tag? Can any data then be used? Why is there a focus on "html"? Wouldn't a way to import any kind of file as a string be better(like https://github.com/webpack-contrib/raw-loader)?
@goldingdamien thanks for the question. If all you want to do is to import a file as a string, I would recommend the very handy Fetch API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
<script> tags can be used to load many things. Indeed, there is a classic strategy for loading JSON across origins with a <script> called JSONP. The main limitation is that any content loaded with a <script> today is parsed as JavaScript.