Dynamic Text - Javascript is not execute function before grafana refresh

Hi Team, I’m new in Grafana and I’m using dynamic text to create a little function that changes the color of the row of the table if the date is bigger than the actual date, the code is working correctly but the problem is that only works after I click in the refresh button and not when the dashboard is loading and is not ideal if I using playlists to show several dashboards If any know how to make that works as soon the dashboard is load? Thanks.