Use visibility conditions to speed up sub-menus

When using script to provide whole menu system, use new type=submenu to
list submenu. See readme.