Rerun custom code when page loads

Hi!
Im using use finsweet load attribute to add filtering on a news page.
I have some custom code added before the body tag.

At first that the filter only worked on the first page. To deal with this, I added the finsweet cms load attribute with the pagination option. The filter works now like a charm but the other scripts only works on the first page.

Is there a way to rerun the code everytime new items are loaded in?

Im not to sure where to start since Im still a little pup :dog: when it comes to coding. Can I use a
some kind of onload function to relaod my script. Im confuse.

Did you find a solution for this?