Code Works in Preview but not in Published?

Could the problem be a needed $w(“#dataset1”).onReady( () => {…

} ); ?