JavaScript for PortableInfoboxes MediaCollections and CollapislbeGroups initialization was executed once while loading the file - so it was working propery for most common case which is displaying article (the view page). However sometimes content is loaded dynamically, after JavaScript already loaded and executed, and for such cases intialization was not happening. In particular such case is loading article preview from within the Classic Editor. Problem is solved by using solid and common MW approach of MediaWiki JavaScript hooks - specifically one named 'wikipage.content' which is meant to be fired whenever wikipage (in any context) is being displayed.