Need new syntax for value passed in `js` common attribute
Currently, the syntax to pass value in js is:
-- ftd.text: Hello
js: bar.js:type=module
Problems:
- First of all the syntax could be better.
- Also, this syntax limits us to not passing
httporhttpsprotocol in the link.
The below code will not work:
-- ftd.text: Hello
js: https://unpkg.com/[email protected]/dist/index.js:type=text/javascript
So we need to remove http or https protocol from the link.
-- ftd.text: Hello
js: //unpkg.com/[email protected]/dist/index.js:type=text/javascript
Therefore, we need a better syntax for this.
Some suggestions for new syntax
Syntax 1:
-- ftd.text: Hello
js: { src = bar.js, type = module }
Syntax 2:
-- ftd.text: Hello
js: bar.js | type = module
We are open for any syntax suggestions
How about both js: and js-module:. What possible values we can pass to type?
As per MDN, the possible values of type are module, importmap, blocking, and any valid content type can be used as type if the content of script tag is not meant to be JavaScript.
For our purpose only type: module is relevant. So we will do js and js-module.
we can use some other alternatives like
syntax 1) -- ftd.text: Hello js: src:bar.js module
Here we have use colon (:) to separate the key-value pairs. The src key represents the source file (bar.js), and the module key indicates the module type.
syntax 2) -- ftd.text: Hello js: bar.js(module)
source file (bar.js) followed by the module type (module).
To include the HTTP or HTTPS protocol in the link while using the simplified syntax
js: https://anything.com/bar.js(module)
We have one more option:
js: https://anything.com/bar.js as module
that would be more simple and easy to understand
Why don't you take a stab at implementing it @HarshikaAdarsh? Should not be too easy. If you are interested you can come say hello on our discord, #fastn-contributors channel and we can guide you more.
@amitu @Arpita-Jaiswal Let me work on this issue