Remove portal code from site when not used

<script defer src="https://unpkg.com/@tryghost/portal@~1.0.0/umd/portal.min.js" ....></script><style> .gh-post-upgrade-cta-content ....

I do not use Portal feature as my theme has its own membership sites. After I disabled the Portal feature in Ghost Admin, there should be no Portal code inserted to the site anymore.

Why load scripts and styles even the feature is not used?

Any solution to remove the code?

2 Likes

As explained here: Remove portal code from site when not used · Issue #12835 · TryGhost/Ghost · GitHub

The script is still in use.

Is there someway to reduce the size of the package or somehow defer it?
It seems to mess with pagespeed insights scores

1 Like

time to return to Wordpress LOL

@Boryl No need. Load if locally, not a third party. That way you control its content and more.

I can only reproduce getting portal to appear in “Remove unused javascript” if I also have other unused JavaScript on the page. i.e. it alone doesn’t pass the threshold.

The script is also already included with “defer”.

I recommend making sure you run lighthouse in an incognito window as well to ensure you’re getting correct and consistent reports.

We are constantly reviewing the script to keep it as small as possible, and we regularly review lighthouse to ensure there are no issues cropping up. The script is 70kb gzipped, I’m not sure why lighthouse reports it larger but will review this.

Actually, it is a global problem today, due to the misunderstanding of application development in the technologies used.

As a specialist in the optimization of Core Web Vitals, I can contribute that the problem does not come from a file size, but from the language used.

React is incompatible with a very high spectrum range of mobile devices. Well, React was not conceived to replace Javascript, if not to solve a specific problem.

The mistake at the global level is to use React, instead of Javascript, when the second is really required.

This means that if Portal were developed in Vanilla Javascript, we would eliminate this warning and various incompatibilities, inherited from React, and it would increase efficiency in a wider spectrum of mobile devices.

1 Like