The build system for my new plugin has two output JS files, one for browsers that support ES modules, one for browsers that don't. At present, I'm only passing one of them into Datasette.
I'd like to specify the non-es-module script as a fallback for older browsers. I don't want to load it by default, because browsers will only need one, and it's heavy, so for now I'm only supporting modern browsers.
To be able to support legacy browsers without slowing down users with modern browsers, I would like to be able to set additional HTML attributes on the tag fallback script, nomodule and defer. My injected scripts should look something like this:
To achieve this, I propose additional optional properties to the API accepted by the extra_js_urls hook and custom JS field the metadata.jsondescribed here.
Under this API, I'd write something like this to get the above HTML rendered in Datasette.
There may be other properties that could be added that are potentially valuable, like async or referrerpolicy, but I don't have an immediate need for those.
Motivation
To be able to support legacy browsers without slowing down users with modern browsers, I would like to be able to set additional HTML attributes on the tag fallback script,
nomodule
anddefer
. My injected scripts should look something like this:Proposal
To achieve this, I propose additional optional properties to the API accepted by the
extra_js_urls
hook and custom JS field themetadata.json
described here.Under this API, I'd write something like this to get the above HTML rendered in Datasette.
Resources
async
orreferrerpolicy
, but I don't have an immediate need for those.