optimize scripts
This commit is contained in:
parent
8cd6a72dd3
commit
d4da02318d
|
@ -40,7 +40,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="css/app.css" />
|
||||
@if (!string.IsNullOrEmpty(_PWAScript))
|
||||
@if (_scripts.Contains("PWA Manifest"))
|
||||
{
|
||||
<link id="app-manifest" rel="manifest" />
|
||||
}
|
||||
|
@ -74,9 +74,7 @@
|
|||
<script src="js/loadjs.min.js"></script>
|
||||
<script src="js/interop.js"></script>
|
||||
|
||||
@((MarkupString)_reconnectScript)
|
||||
@((MarkupString)_PWAScript)
|
||||
@((MarkupString)_scrollPositionScript)
|
||||
@((MarkupString)_scripts)
|
||||
@((MarkupString)_bodyResources)
|
||||
}
|
||||
else
|
||||
|
@ -101,9 +99,7 @@
|
|||
private string _headResources = "";
|
||||
private string _bodyResources = "";
|
||||
private string _styleSheets = "";
|
||||
private string _reconnectScript = ""; // for Interactive render mode and Blazor Server interactivity only
|
||||
private string _PWAScript = ""; // for PWA apps only
|
||||
private string _scrollPositionScript = ""; // for Static render mode only
|
||||
private string _scripts = "";
|
||||
private string _message = "";
|
||||
private PageState _pageState;
|
||||
|
||||
|
@ -177,17 +173,18 @@
|
|||
ManageStyleSheets(resources);
|
||||
ManageScripts(resources, alias);
|
||||
|
||||
// generate scripts
|
||||
if (_renderMode == RenderModes.Interactive && _runtime == Runtimes.Server)
|
||||
{
|
||||
_reconnectScript = CreateReconnectScript();
|
||||
_scripts += CreateReconnectScript();
|
||||
}
|
||||
if (site.PwaIsEnabled && site.PwaAppIconFileId != null && site.PwaSplashIconFileId != null)
|
||||
{
|
||||
_PWAScript = CreatePWAScript(alias, site, route);
|
||||
_scripts += CreatePWAScript(alias, site, route);
|
||||
}
|
||||
@if (_renderMode == RenderModes.Static)
|
||||
{
|
||||
_scrollPositionScript = CreateScrollPositionScript();
|
||||
_scripts += CreateScrollPositionScript();
|
||||
}
|
||||
|
||||
_headResources += ParseScripts(site.HeadContent);
|
||||
|
@ -492,6 +489,7 @@
|
|||
{
|
||||
return
|
||||
"<script>" + Environment.NewLine +
|
||||
" // Static Blazor Scroll Position" + Environment.NewLine +
|
||||
" window.interceptNavigation = () => {" + Environment.NewLine +
|
||||
" let currentUrl = window.location.href;" + Environment.NewLine +
|
||||
" Blazor.addEventListener('enhancedload', () => {" + Environment.NewLine +
|
||||
|
|
Loading…
Reference in New Issue
Block a user