Beispiel #1
0
        public static SpeedyAssetLinks GenerateDeferedLinks(IThemesProvider themesProvider)
        {
            if (AssetContentRefresher.IsPublishing() || IsAddingRendering())
            {
                return(new SpeedyAssetLinks());
            }
            var assetsGenerator = new SpeedyAssetLinksGenerator();
            var links           = assetsGenerator.GenerateSpeedyAssetLinks(themesProvider);
            var linkSpeedy      = new SpeedyAssetLinks(links);

            var AreScriptsDeferred = SpeedyGenerationSettings.IsCriticalJavascriptEnabledAndPossible(Sitecore.Context.Item);

            if (AreScriptsDeferred)
            {
                string deferredSriptsCacheKey = $"speedy-deferred-page-scripts-{Sitecore.Context.Item.ID}";
                string preloadSriptsCacheKey  = $"speedy-preload-page-scripts-{Sitecore.Context.Item.ID}";
                string deferredSriptsCache    = HttpContext.Current.Cache[deferredSriptsCacheKey] as string;
                string preloadSriptsCache     = HttpContext.Current.Cache[preloadSriptsCacheKey] as string;

                if (SpeedyGenerationSettings.IsDebugModeEnabled())
                {
                    deferredSriptsCache = null;
                    preloadSriptsCache  = null;
                }

                if (!string.IsNullOrWhiteSpace(deferredSriptsCache) && !string.IsNullOrWhiteSpace(preloadSriptsCache))
                {
                    linkSpeedy.ClientScriptsRendered = deferredSriptsCache;
                    linkSpeedy.ClientScriptsPreload  = preloadSriptsCache;
                }
                else
                {
                    assetsGenerator.GenerateSpeedyScripts(linkSpeedy);
                    CacheObject(deferredSriptsCacheKey, linkSpeedy.ClientScriptsRendered, GetDependencies(null));
                    CacheObject(preloadSriptsCacheKey, linkSpeedy.ClientScriptsPreload, GetDependencies(null));
                }
            }
            else
            {
                var linksa = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
                linkSpeedy.Scripts = linksa.Scripts;
            }
            return(linkSpeedy);
        }
Beispiel #2
0
        public static SpeedyAssetLinks GenerateDeferedLinks(IThemesProvider themesProvider)
        {
            if (AssetContentRefresher.IsPublishing() || IsAddingRendering())
            {
                return(new SpeedyAssetLinks());
            }
            var assetsGenerator = new SpeedyAssetLinksGenerator();
            var links           = assetsGenerator.GenerateSpeedyAssetLinks(themesProvider);
            var linkSpeedy      = new SpeedyAssetLinks(links);

            var AreScriptsDeferred = SpeedyGenerationSettings.IsCriticalJavascriptEnabledAndPossible(Sitecore.Context.Item);

            if (AreScriptsDeferred)
            {
                assetsGenerator.GenerateSpeedyScripts(linkSpeedy);
            }
            else
            {
                var linksa = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
                linkSpeedy.Scripts = linksa.Scripts;
            }
            return(linkSpeedy);
        }