stefanbohacek / fediverse-embeds-wordpress-plugin

Embed fediverse posts on your WordPress site.
https://wordpress.org/plugins/fediverse-embeds/
MIT License
39 stars 1 forks source link

Enhancement: library/CSS loaded in header globally #25

Closed cybeardjm closed 2 months ago

cybeardjm commented 1 year ago

Hi, Just noticed that the plugin's library & CSS are loaded on everywhere on the site...

in the header. Would it be possible to:

stefanbohacek commented 12 months ago

@cybeardjm It does make sense to limit loading the JS/CSS only when an embed is on the page, good call.

The tricky part here is that you can really embed a post on any page, not just a post/page. For example, here's a tag page on my website, which shows the tag description, and could easily include an embedded post.

I am going to need to look into the performance trade-offs in terms of necessary database queries.

In the meantime, I checked one of your sites and I do see the JS loaded in the footer, as it should, since I am registering the script to be in the footer. Plus, I am also using the defer script tag attribute, so the impact should really be minimal.

As for the CSS file, including it outside of the head element is not really commonly done, see:

cybeardjm commented 12 months ago

Been playing with various cache plugins (with gzip + other defer/swap techniques) and speed-testing platforms, this is why I've suggested this, as these CS/JS appear in most "complaints"... If it's possible, would be a "+".

stefanbohacek commented 12 months ago

Sure, that makes sense.

On a side note, I will add that the plugin still provides a huge performance boost compared to the default embed method, at least for Mastodon.

Either way, I'll definitely look into this some more. Thank you for bringing this up!

cybeardjm commented 12 months ago

Was thinking: loading on individual posts (even if no fedi embedded content) is probably not a huge problem, but at least the plugin should offer the option to deactivate (or not) for pages (including) via a checkbox in the settings.

FYI: https://www.didiermary.fr/wp-content/plugins/fediverse-embeds/dist/css/styles-bs.min.css 32.3 KB - 300 ms

DJM

On Sat, Nov 25, 2023 at 11:12 PM Stefan Bohacek @.***> wrote:

Sure, that makes sense.

On a side note, I will add that the plugin still provides a huge performance boost https://stefanbohacek.com/project/wordpress-plugin-for-fediverse-embeds/#performance compared to the default embed method, at least for Mastodon.

Either way, I'll definitely look into this some more. Thank you for bringing this up!

— Reply to this email directly, view it on GitHub https://github.com/stefanbohacek/fediverse-embeds-wordpress-plugin/issues/25#issuecomment-1826430547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMQ4RP5NVOSVSQRAW33YCD3YGJUMZAVCNFSM6AAAAAA7YH6GZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGQZTANJUG4 . You are receiving this because you were mentioned.Message ID: <stefanbohacek/fediverse-embeds-wordpress-plugin/issues/25/1826430547@ github.com>

stefanbohacek commented 12 months ago

@cybeardjm Yes, adding an option to customize the behavior and let the user decide makes a lot of sense. Thank you for the suggestion!

stefanbohacek commented 2 months ago

Fixed in https://github.com/stefanbohacek/fediverse-embeds-wordpress-plugin/commit/932f2ab0393ed750405334c073b71430439bff1a and https://github.com/stefanbohacek/fediverse-embeds-wordpress-plugin/commit/91ff2db2497cd5e5f5024682107d287924697006.