Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Would this be a good feature to request?

Hey gang,

I was wondering if it would be a good feature to be able to either tag a passage that would contain all of the things you want to add to the <head></head> space, or alternatively it could be in that little triangle pop-up button in the editor.

Thoughts?

My idea is that since people are always asking about how to add this or that after the fact, maybe this could inject whatever the wrote there? Things like calling a CSS or a JS or what-have-you.

Yes... they could inadvertently break something in their own story, but I think this is already the case, no?

Anyway... that's my idea. I just wondered if anyone else thought it had merit enough to be an official suggestion.

Sage

PS, if this already exists, please tell me where. Ha!

Comments

  • edited July 2015
    It exists in Twine 1 already. You just edit the header. It's the main reason I use Twine 1 over 2.
  • Oh! Cool. Thanks.
  • edited July 2015
    Twine 1 SugarCube also lets you make a file called "userlib.js" and stick it in the same directory as the header. It'll then import that JavaScript.

    Aside from altering the html file after publish (which is obviously bad due to workflow issues, since it precludes easy testing if you need to alter the HTML before every single test), it's also the only way to get GreenSock Animation into Twine currently.


    That said, stuff like this is still a decent Twine 2 request, due to how powerful some of this can be.
  • edited July 2015
    Hey, @Claretta

    I thought that it might help you to see what Chris' idea was for a workaround (in case you had ANY desire to migrate over to 2). Here it is, below:

    From @Klembot
    "Head section" Includes

    Well, a workaround for this for now is, instead of copy/pasting code, is to put this in your story CSS:

    @import url('path/to/my/external/library.css');

    Likewise for JS:

    var e = document.createElement('script');
    e.setAttribute('src', 'path/to/my/external/library.js');
    document.querySelector('body').appendChild(e);

    If the purpose of this is to include external libraries, then let's talk about a UI for that. I'm leery of a general purpose <head> UI because authors who don't know HTML won't know what it means, and entering bad HTML would break your story output in a way that would not be obvious.

    I'm also not sure if the appropriate place to do this is inside the editor. I could see a case made for story formats to provide this so that loading these libraries happens at the right time during the story's initial load.

    I also included @TheMadExile (but only because you're a developer... no real reason for you to respond).
  • As I noted in the issue you opened, what CK is describing and what Claretta is doing are two different things (linking to external resources vs. inlining resources).
Sign In or Register to comment.