danurbanowicz / eleventy-netlify-boilerplate

A template for building a blog with the Eleventy static site generator and Decap CMS
https://eleventy-netlify-boilerplate.netlify.app/
MIT License
528 stars 183 forks source link

Bulky netlify-identity-widget script include #39

Closed wachunga closed 4 years ago

wachunga commented 4 years ago

netlify-identity-widget.js is adding 184kb (unminified) js to each page. Is it possible to restrict that to only necessary pages? https://github.com/danurbanowicz/eleventy-netlify-boilerplate/blob/master/_includes/components/head.njk#L6

I like to keep the page weight low :)

image

danurbanowicz commented 4 years ago

Thanks for this.

I absolutely agree with you, and I had the same concerns back when the PR including this behaviour was made by the big boss of Netlify himself :fearful: but there didn't actually seem to be a good way around it at the time.

I think it's there because of the way Netlify Identity works on invite signups, but if you have any ideas on how it could be offloaded from the frontend, I'm all ears!

danurbanowicz commented 4 years ago

Possible alternatives to loading the Identity widget on every single page, could be to either:-

Load the widget only on the site's root / e.g.

_includes/components/head.njk

{% if page.url == "/" %}
  <script async src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
{% endif %}

or set up Netlify Identity email templates, modifying the Identity invite email link to point to somewhere like /admin/index.html or perhaps a separate page where you load the Identity widget.

Closing this for now but I will re-open if there is still interest in the issue.

wachunga commented 4 years ago

Thanks, that works.