Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

How to go block-less with the WordPress ActivityPub plugin

  • Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

    For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

    To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

    Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

    Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class and with quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looked pretty nice (and similar to the JavaScript-rendered one).

    If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

  • pfefferle@mastodon.socialundefined pfefferle@mastodon.social shared this topic on
  • Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

    For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

    To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

    Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

    Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class and with quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looked pretty nice (and similar to the JavaScript-rendered one).

    If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

    @frank awesome! would you maybe like to contribute this to the plugin? I am thinking about a snippets "directory", to show how the plugin can be extended with special features!?

    I will create a barebone folder with a readme for that!?

  • Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

    For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

    To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

    Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

    Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class and with quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looked pretty nice (and similar to the JavaScript-rendered one).

    If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

    @frank @pfefferle

    I have a blockless theme. There are a bunch of things which I deactivate.

    See https://gitlab.com/edent/blog-theme/-/blob/master/includes/remove.php?ref_type=heads#L127

    I don't have reactions though. I keep going back and forth about whether I want them and whether it is possible to back-fill them.

  • @frank awesome! would you maybe like to contribute this to the plugin? I am thinking about a snippets "directory", to show how the plugin can be extended with special features!?

    I will create a barebone folder with a readme for that!?

    @pfefferle sure, will be happy to contribute this 🙂

  • @frank @pfefferle

    I have a blockless theme. There are a bunch of things which I deactivate.

    See https://gitlab.com/edent/blog-theme/-/blob/master/includes/remove.php?ref_type=heads#L127

    I don't have reactions though. I keep going back and forth about whether I want them and whether it is possible to back-fill them.

    @Edent @frank that looks way nicer than our current "static" implementation in the Webmentions plugin btw.

    what do you think: https://github.com/Automattic/wordpress-activitypub/pull/2909

  • @frank @pfefferle

    I have a blockless theme. There are a bunch of things which I deactivate.

    See https://gitlab.com/edent/blog-theme/-/blob/master/includes/remove.php?ref_type=heads#L127

    I don't have reactions though. I keep going back and forth about whether I want them and whether it is possible to back-fill them.

    @Edent You’re removing a lot as well, good job 🙂 What do you mean with “possible to back-fill them” Terence?

  • @Edent You’re removing a lot as well, good job 🙂 What do you mean with “possible to back-fill them” Terence?

    @frank
    As I understand it, likes and reposts are sent as comments. I've deleted / rejected all of those comments.
    How do I get back the likes and reposts of old posts?

    I guess I could look at the posts and manually grab the ⭐ and ♻️ - but I wonder if there's an automated way.

  • @frank
    As I understand it, likes and reposts are sent as comments. I've deleted / rejected all of those comments.
    How do I get back the likes and reposts of old posts?

    I guess I could look at the posts and manually grab the ⭐ and ♻️ - but I wonder if there's an automated way.

    @Edent I guess that if you deleted them, there’s no automated way to get them back?

  • Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

    For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

    To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

    Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

    Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class and with quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looked pretty nice (and similar to the JavaScript-rendered one).

    If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

    @frank @pfefferle Great ! Nice Frank

  • Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

    For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

    To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

    Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

    Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class and with quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looked pretty nice (and similar to the JavaScript-rendered one).

    If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

    @frank this has now cleaned up and added as one of the snippets that are available in the @activitypub.blog plugin by @pfefferle , see https://github.com/Automattic/wordpress-activitypub/tree/trunk/snippets/blockless-activitypub


Gli ultimi otto messaggi ricevuti dalla Federazione
Post suggeriti
  • 0 Votes
    1 Posts
    5 Views
    If you’re an old-time blogger, you probably remember Freshly Pressed. 16 years ago (!), the folks at WordPress.com launched a new blog where they highlighted interesting blog posts from the WordPress.com community every week. We iterated on the idea a few times over the years but the main idea stayed the same:a curated collection of posts that entertained, enlightened, and inspired. It was our way of saying “we like you, we really like you” to creators, and amplifying their great work for others to find. Great Writing Deserves a Spotlight: Freshly Pressed Is BackFreshly Pressed went away for the past few years, but I’m happy to say that my team brought it back! It’s got a fresh coat of paint and most importantly, it’s got quite a few interesting blog posts already!Im really happy and proud that we were able to get this done. Today, more than ever, I think we could use a bit more humanity on the web.The old web felt like a city. You could turn down a random alley and find a weird little shop. You could get lost and discover something beautiful by accident. You could end up in a tiny shop you didn’t know existed or sit on a bench and people-watch.Now it’s a mall. Every path leads past a store. Every store wants something from you. Even the “public” space is engineered to keep you moving toward purchase.Straight from today’s Freshly Pressed post, I miss being unmarketable on the internet.So check some of those blogs out. Give them a Like. Leave a comment. Start following them. And if you find good potential candidates for the next Freshly Pressed post, send them my way! All you need to be featured is a WordPress.com or self-hosted WordPress site running the Jetpack plugin, and most importantly, an interesting, or funny, or unique story to tell! Bonus: if you’re more of an RSS person, you can also get Freshly Pressed posts straight in your RSS reader via this feed. Pinging @davew, I know you’re always looking for good feeds 🙂
  • 0 Votes
    7 Posts
    22 Views
    @awiro_median @awiro-median 👋 habt ihr den WP-Cron richtig konfiguriert? Die Bestätigung wird über den Cron verschickt und wenn der nicht oder nur selten läuft, funktioniert es nicht oder dauert entsprechend.
  • 0 Votes
    1 Posts
    5 Views
    あのアカウントの人、#WordPress のプラグイン #ActivityPub の更新をしてないな…。たぶん。
  • 0 Votes
    1 Posts
    20 Views
    Is there anyone who updates their FreeBSD from source with extra optimisation, such as -O3 -march=native (and maybe LTO)? What is the impact on the FreeBSD system if the source is compiled with extra optimisations? Correct me if i am wrong about optimisation in clang.#freebsd #source #update #performance