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
    8 Views
    Non si parla delle persone assenti.Comparse e scomparse nel presepe di Luzzati.Performance e installazione, 2025.Giardini Sambuy, piazza Carlo Felice, Torino.https://roccioletti.com/2025/12/16/non-si-parla-delle-persone-assenti/#performance #installazione #installation #contemporaryart #art #photography
  • 0 Votes
    1 Posts
    6 Views
    RE: https://climatejustice.social/@stefanmuelller/115673891992319316Kann mir jemand erklären, wieso dieser Blog-Post nicht angezeigt wird? Das ist #Wordpress mit #activitypub aber irgendwie geht das nicht. Beim #OstBlog geht alles. Ich finde aber keine Einstellung, die ich ändern könnte.Es heißt einefach immer "Beitragsveröffentlichung ausstehend".#FollowerPower
  • 0 Votes
    1 Posts
    10 Views
    Over at WordPress.com, we recently added a new feature to the WordPress.com Reader. You can now build a list of blogs you like, and recommend them to others.What if your readers could help your blog grow? What if the writers you love could introduce their audience to yours?That’s the idea behind recommended blogs, a feature now available in the WordPress.com Reader that lets you share the blogs you enjoy most with your own audience.Let’s Grow Together: Introducing Recommended Blogs Since the WordPress.com Reader lets you follow any site that supports RSS, you can recommend blogs on any platform or CMS. As long as the site includes an RSS feed, you’ll be good to go!You can view my recommended blogs in my WordPress.com Reader profile. Ever the champion of the Open Web, @davew asked me if one could fetch those recommended blogs to show in their own app or tools. Since this is WordPress.com, recommended blogs are indeed available via the WordPress.com REST API. There are different endpoints one can use to fetch and show recommended blogs. All you need to get started is a WordPress.com username.Side-note: WordPress.com usernames are also Gravatar usernames, so once you have a Gravatar username, you can show all sorts of information the person chose to make public in their profile:Check our API documentation to find out more.Once you have a WordPress.com username, you can make a request to rest/v1.2/read/lists/<username>/recommended-blogs/items to get a list of their recommended blogs:We also have another endpoint you can use to export the list in OPML format: wpcom/v2/read/lists/<list-ID>/export. You can get that list ID from the API response just above. That can be handy if you then want to import the list in your own Reader!If you haven’t tried the WordPress.com Reader yet, this could be a good opportunity to give it a try!
  • 0 Votes
    1 Posts
    3 Views
    No one has replied