html-modules-toolkit icon indicating copy to clipboard operation
html-modules-toolkit copied to clipboard

Script tag with html module?

Open goldingdamien opened this issue 6 years ago • 1 comments
trafficstars

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 avatar Feb 25 '19 07:02 goldingdamien

@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.

cdata avatar May 17 '19 14:05 cdata