public static XElement[] Scripts(bool isDebug = false) { var scripts = HtmlJavaScriptSynchronizer.Scripts(new XElementProvider(), isDebug); return(scripts.Where(element => element.Name == "meta") .Concat( new[] { new XElement("script", new XAttribute("type", "text/javascript"), new XRaw( @" function server_event(json) { window.external.Event(json); } " ) ) } ) .Concat(scripts.Where(element => element.Name != "meta")) .ToArray()); }