Alternative to requires-comment for CDNs
When I'm using files I'm not in control of, like a CDN, I'm not able to add the line of // requires: file.js. How can I hint script dependencies when I'm linking to the outside.
Hack: Meanwhile It's possible to add the script-tag in the html-partial.
The "hack" mentioned by @gurre above will work for now, but keep in mind that if the library needs jQuery, you might want to use a CDN for that as well (don't forget the remove the library from the assets/js/libs folder, too, or you'll have two versions loaded in).
I've attached this to the v1.2 milestone, which will be the next minor release.
@gurre I was just looking into this and there doesn't seem to be an obvious solution I'm afraid. Besides that, I am not convinced by the benefit of serving from a CDN. That is, not in one of the 2 cases:
- Serving some libs from CDN, and having the rest local ... meh. You have more requests, and are now dependent of other servers. If your site is down, it's down. No matter where you host your bits and pieces. Since Headstart concatenates everything for you, I think one request will still be faster than multiple + CDN reqs (not tested!).
- Serving EVERYTHING from a CDN, including images, stylesheets; the whole lot. This is good, and will probably be faster (again, not tested!). This is also something I can implement (eg. by prefixing all assets references with a certain URL).
But maybe there are other cases that I haven't thought of; so ... what was your motivation of adding this issue?
Well, I serve images from S3 over CloudFront, foremost retina 2x-sizes. Secondly, third-party js such as social and analytics.
It's probably faster to serve on a open connection, compared to opening a new to a CDN, however in some cases you don't have that option as a developer on a particular job.
There's also the prefetch meta tag which should prepare a connection to any provided domain.
Stylesheets and images are the easiest to manage by hand imo, as there shouldn't be any dependencies.
I might be able to figure out a comment-based way of managing CDN script dependencies, but since Headstart concatenates stuff automatically, it would mean splitting that file up and around the CDN scripts, and just thinking about it makes my head esplode 😵
I'll be adding features in every 1.x release, so maybe this will be one of them, but I can't pin you an exact date unfortunately..