First off, it looks like you are adding JavaScript to PHP. That is why you have a mistake.
As for the problem with the blinking menu, you should set the display: none; submenu display: none; in CSS. Looking at the plugin, he sets it (submenu) to display: none; , but it does not work until the DOM loads (which after a short time after loading the page comes in, but enough to see that "), therefore, setting it to display: none; in CSS, it will be hidden and will open when freezing.
In particular, after looking at the plugin in the link, try adding the following to your CSS:
.dcjq-vertical-mega-menu .sub-container { display: none; }
source share