Improved JS script that decides if a widget needs re-rendering