NoDivide / astrum

A lightweight pattern library designed to be included with any web project.
http://astrum.nodividestudio.com
1.54k stars 98 forks source link

Add ability to reference scripts in the head #108

Open yellowled opened 7 years ago

yellowled commented 7 years ago

A few JS components (Modernizr, for instance) require or at least prefer to be included in the <head> (before including stylesheets) to work properly.

As far as I can see, this is currently possible in Astrum only by editing the index.html and hard-coding the reference to said scripts. That is inconvenient and prone to error. Also, the index.html might be overwritten by astrum update due to changes to it, I guess?

I think it might help to have an additional i.e. head in assets.

yellowled commented 7 years ago

Sorry, I would have added the “Feature request” label to this issue, but it seems I'm not allowed to. Labels etc. is disabled for me even after posting the issue.

matt-west commented 7 years ago

@RyanHavoc I think we didn't do this to begin with because of a scoping issue with Vue but we later restructured the app so it should be possible now (am I remembering correctly?).

Branching the config would be the simplest way to implement this. Much of the templating code to stamp out the <script> elements is already there.

"assets": {
    "css": [],
    "js": {
        "head": [ ... ],
        "foot": [ ... ]
    }
},
yellowled commented 7 years ago

Just for the record, I know of no CSS that needs to be emitted in the foot. If it's easier to implement that way, I'd add a hint to the documentation that it's not exactly considered best practice to emit CSS somewhere else than in the <head>.

RyanHavoc commented 7 years ago

@yellowled Ha, I'm sure that was just a copy and paste typo. :-)

@matt-west No there shouldn't be any reason why we can't do this now. I'll mark it down to be implemented in version 2.

matt-west commented 7 years ago

@yellowled Haha, sorry. My brain hadn't woken up yet.

yellowled commented 7 years ago

@matt-west Well, there's one upside of time zones – mine's already wide awake. 😉