klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2k stars 295 forks source link

Allow story authors to provide material to be included in the head of the story file #1334

Open david-donachie opened 1 year ago

david-donachie commented 1 year ago

Is your feature request related to a problem? Please describe.

Story authors must wait until a story is entirely loaded (including the story format) before being able to load content, such as external fonts or preloaded images, that would be best loaded in the document HEAD as the rest of the game loads. Similarly, there is no way for a story author to insert content (such as Google Analytics scripts) that only works in the document HEAD.

It has been suggested that this is a compiler issue, rather than a story format issue, since story formats are not loaded until after the point where head content should have been inserted.

My particular issue was to do with styling the loading screen in SugarCube (which you can't easily do, since the screen loads before any part of the user-content), but it's a wider problem.

Describe the solution you'd like.

Add a new section to the Story menu "Head Content" that will allow you to insert content into the head of the compiled file. It's content would probably be raw HTML

Describe alternatives you've considered.

I initially considered this something a StoryFormat could do, and suggested various solutions on a SugarCube issue, but the problem applies equally to all StoryFormats.

It's also the case that tweego can handle this easily by marking a stylesheet or script as head content, but I feel it should be possible to use the Twine application to do the same without having to resort to external compilers or manual editing.

Additional context on this suggestion.

No response

Presubmission checklist

klembot commented 1 year ago

I'm going close #164 as a duplicate of this because I think this has a better description of use cases, etc. FWIW, Google Analytics recommends putting its tag after the <head> section which would be potentially even more confusing to implement. But I get that this is just one example use case.

Amathele commented 1 year ago

Maybe add a way to set the FavIcon of the generated HMTL per Story.? Didn't know if this warranted a new Issue