In case you missed it in the release notes today, here’s the patch I’ve wanted for a long time that solves a whole bunch of “we can’t change it because its in ghost_head” problems.
Among (many, many) other things, it’s a way to load a custom version of the portal on Ghost Pro.
Many thanks to @vikaspotluri123 for help with broken tests, to multiple members of the Ghost dev team for nudging me along when I got stuck, and especially to @hannah for helping me work out what the options should (and shouldn’t) be.
p.s. Wanna know the really sad thing? My own site is a couple minor versions back and stuck there until I make some time to dig into the problem, so I can’t actually use it! Yet…
I’m super interested to hear how you use it and where it falls short. I didn’t realize that I needed {{content_api_url}} until I went to write the examples, and there might be other needs. Examples with use cases would be a good way to advocate for additions or new helpers.
(And yes, content_api_url and _key are also available now!)
And @markstos , I tried to add in suppression of the generator bit, and lost that argument. (In fairness, Hannah was right that it didn’t seem like something a theme should control.)
I suspect that a PR that added an argument in config.<env>.json would probably get merged. My first write of the ghost_head changes actually included it and took a config.json argument (not an argument to ghost_head), so it should be possible to resurrect some of that work, just for the generator line. This commit shows what I cut /out/ to switch strategies. Feel free to grab anything useful there. updated design (inline exclude) and updated tests · TryGhost/Ghost@4add875 · GitHub
[Unless someone funds it, I’m not going to get to it any time soon, so if you want it, please put in the PR!]
I have often wanted to get rid of search/portal code for sites that don’t need it, to get better performance and pageespeed scores. Now I can — without doing anything hacky!
I wrote some code to suppress Stripe in an early draft that didn’t survive the discussion/rewrites/refinements/improvements necessary to get it merged.
As I understand it, the Stripe script only loads if Stripe is actually configured. (ghost_head checks the settings cache for paid_members_enabled). As a result, I didn’t have a great argument or use case for excluding the script, but if you have one, please share it! I would be happy to take an argument for suppressing Stripe back to the dev team.
We did have some discussion about how it could probably be switched to ‘defer’ instead of async, that I don’t think has gotten any follow-up yet. (I at least haven’t done anything with it.)
If you’re seeing Stripe load when it should not (when not configured or no paid memberships available), please provide some details! That would be a bug. :)
I think there’s an interesting discussion to be had about how Ghost could offer better support (tiers, etc) for sites that aren’t connected to Stripe, but that probably needs a separate post over in the ideas forum, rather than here.
Hey! @Cathy_Sarisky thanks a lot for your detailed explanation! really appreciate it.
And yes, basically I’m optimizing as much as possible our themes, so the script is generating a medium delay on the website: Screenshot by Lightshot so i’m moving all possible scripts from “head” to a more optimized location and with different parameters as “defer”.
It is pretty common on Custom Theme, that we as authors create a dedicated “membership” page, so the portal buttons and other functionalities can be safely omitted and optimized.
Anyway, I just did some quick tests and got very consistent and good results with this change, thank you again for this contribution it was really needed.