I keep struggling with getting JavaScript executed when I need to target a DOM element that is added via the BigPipe module when I’m logged in on my Drupal site.
The following code runs when I’m not logged in, but it’s never executed when I am logged in.
(function ($) { 'use strict'; Drupal.behavior.bpBlockTest = { attach: function(context, settings) { $('.my-block', context).once('bp-block-testing').each(function () { var $myBlock = $(this); var $addOn = $('<span>addOn</span>'); $addOn.appendTo($myBlock); }); } } }(jQuery));