# Pagespeed performance, inline js and css

**URL:** <https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713>\
**Category:** Developer help\
**Created:** [October 24, 2018, 8:30am UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713 "2018-10-24T08:30:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![giacomosilli](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/giacomosilli/32/3403_2.png) [@giacomosilli](https://forum.ghost.org/u/giacomosilli)\
**Post date:** [October 24, 2018, 8:30am UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/1 "2018-10-24T08:30:54Z")

</div>

I’m trying to maximize the performance of my blog.

Pagespeed complains a bit about everything, I’m trying to make it happy.

Adding the content of the file ghost-sdk.min.js and built / screen.css directly into the default.hbs file is a bad practice or does not involve particular annoyances? thank you

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [October 24, 2018, 10:41am UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/2 "2018-10-24T10:41:17Z")

</div>

It’s not possible to disable the injection of the `ghost-sdk.min.js` file at the moment due to backwards-compatibility although we hope to be able to remove it as a breaking change in Ghost 3.0.

We are looking at ways to improve it’s effects on performance audits in the meantime.

> <https://github.com/TryGhost/Ghost/issues/9991>
>
> Currently we inject ghost-sdk.js into themes as follows:
> 
> \`\`\`
> \<script src="/p…ublic/ghost-sdk.min.js?v=30b82fce68"\>\</script\>
> \<script\>
> ghost.init({
> clientId: "ghost-frontend",
> clientSecret: "f84a07a72b17"
> });
> \</script\>
> \`\`\`
> 
> and Google Pagespeed doesn't like it
> 
> !\[image\](https://user-images.githubusercontent.com/120485/46848106-3775cb80-ce12-11e8-84ae-a4e0850c4641.png)
> 
> \---
> 
> \## Question 1:
> 
> Can we add \`async\` to the script? or, preferably:
> 
> \## Question 2: 
> 
> Could we not just inline the whole thing? It's tiny anyway, and would actually be a reduction of 2 script tags to 1:
> 
> \`\`\`
> \<script\>
> !function(){var o,i,n,e,r="https://demo.ghost.io/ghost/api/v0.1/";n={api:function(){var n,e=Array.prototype.slice.call(arguments),t=r;return(n=e.pop())&&"object"!=typeof n&&(e.push(n),n={}),(n=n||{}).client\_id=o,n.client\_secret=i,e.length&&e.forEach(function(n){t+=n.replace(/^\\/|\\/$/g,"")+"/"}),t+function(n){var e,t=\[\];if(!n)return"";for(e in n)n.hasOwnProperty(e)&&(n\[e\]||!1===n\[e\])&&t.push(e+"="+encodeURIComponent(n\[e\]));return t.length?"?"+t.join("&"):""}(n)}},e=function(n){o=n.clientId?n.clientId:"",i=n.clientSecret?n.clientSecret:"",r=n.url?n.url:r.match(/{\\{api-url}}/)?"":r},"undefined"!=typeof window&&(window.ghost=window.ghost||{},window.ghost.url=n,window.ghost.init=e),"undefined"!=typeof module&&(module.exports={url:n,init:e})}();
> ghost.init({
> clientId: "ghost-frontend",
> clientSecret: "f84a07a72b17"
> });
> \</script\>
> \`\`\`
> 
> \## Question 3:
> 
> Could this also move to \`\</body\>\` instead of \`\</head\>\` ?

---

<div class="post-metadata">

**Author:** ![giacomosilli](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/giacomosilli/32/3403_2.png) [@giacomosilli](https://forum.ghost.org/u/giacomosilli)\
**Post date:** [October 24, 2018, 11:18am UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/3 "2018-10-24T11:18:44Z")

</div>

Thanks for the reply,  
I read this post and I tried to enter the code directly, I have not found any problem.

I had thought to leave it so momentarily if I did not risk compromising the system. Any problems?

And what about the css, is it bad practice?

---

<div class="post-metadata">

**Author:** ![milessmith](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@milessmith](https://forum.ghost.org/u/milessmith)\
**Post date:** [October 24, 2018, 5:08pm UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/4 "2018-10-24T17:08:38Z")

</div>

yes man you are right i also want to know Am facing the same problem. Hope anyone here can help me too. Thanks in advance.  
Regards,  
miles smith  
[ViaMichelin](https://vidmate.onl/) [PutLocker](https://anydesk.vip/) [Google Earth](https://tubemate.vip/)

---

<div class="post-metadata">

**Author:** ![giacomosilli](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/giacomosilli/32/3403_2.png) [@giacomosilli](https://forum.ghost.org/u/giacomosilli)\
**Post date:** [October 25, 2018, 5:15pm UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/5 "2018-10-25T17:15:34Z")

</div>

> [@milessmith](#):
>
> [ViaMichelin](https://vidmate.onl/) [PutLocker](https://anydesk.vip/) [Google Earth](https://tubemate.vip/)

?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [November 8, 2018, 5:26pm UTC](https://forum.ghost.org/t/pagespeed-performance-inline-js-and-css/3713/6 "2018-11-08T17:26:28Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
