I am actively developing some scripts and actions in Drafts that use the HTML Preview Action.
The underling topic - how to set it up and a good HTML document should be created and a great reply by @chrillek - brought me to the following article:
I had to read with some astonishment that the practice of many tutorials to put Java Script inside the body of the HTML document is really bad practice and might even be the reason for some of the things I hate so much in web-apps or on webpages.
As noted in my article
I am looking for a good and compact way to facilitate HTML Preview with my different ideas. The goal would be two fold:
Generate good and nice HTML documents (with much Java Script)
Have simple and compact templates in the Draft action (with template tags)
Take away
As I read the article about the EventListener the practice of Java Script in the body could be completely abandoned by using the load event.
During generation the HTML Preview is not very talkative if a parse/specific error occurs. The EventListenererror event might be a nice way to give the developer more details on the reason of the script.
Why do they have to have “much JavaScript”? Not that I’m against JS, but I think it should be necessary for a certain purpose. So not necessarily “much” but “the JS required for this document”. Eg, prism.js for code highlighting – but jQuery?
It would be difficult to add an onload listener without also adding JavaScript, me thinks. Though I don’t want to curb you enthusiasm, any JS manipulating the DOM is using this event and a listener for it since ages
Again: I suggest to talk about the effect(s) you want to achieve with JS.
JQuery was bloatware and considered a bad example by many JS aficionados.
It is a performance bottleneck, especially with mobile devices. Not necessarily bad code. In the context of Drafts, it might not be an issue at all, since JS is probably only used to get a nice printout. As in your example about nomnoml and mine about code highlighting.