diff --git a/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs b/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs
new file mode 100644
index 0000000000..1ea3c56b5b
--- /dev/null
+++ b/src/Umbraco.Web/UI/JavaScript/AssetInitialization.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Linq;
+using System.Web;
+using ClientDependency.Core;
+using ClientDependency.Core.Config;
+using Newtonsoft.Json.Linq;
+
+namespace Umbraco.Web.UI.JavaScript
+{
+ internal abstract class AssetInitialization
+ {
+ ///
+ /// This will check if we're in release mode, if so it will create a CDF URL to load them all in at once
+ ///
+ ///
+ ///
+ ///
+ protected JArray CheckIfReleaseAndOptimized(JArray fileRefs, ClientDependencyType cdfType)
+ {
+ if (HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled == false)
+ {
+ return GetOptimized(fileRefs, cdfType);
+ }
+ return fileRefs;
+ }
+
+ ///
+ /// Return array of optimized URLs
+ ///
+ ///
+ ///
+ ///
+ protected JArray GetOptimized(JArray fileRefs, ClientDependencyType cdfType)
+ {
+ var depenencies = fileRefs.Select(x =>
+ {
+ var asString = x.ToString();
+ if (asString.StartsWith("/") == false)
+ {
+ if (Uri.IsWellFormedUriString(asString, UriKind.Relative))
+ {
+ var absolute = new Uri(HttpContext.Current.Request.Url, asString);
+ return new BasicFile(cdfType) { FilePath = absolute.AbsolutePath };
+ }
+ return null;
+ }
+ return new JavascriptFile(asString);
+ }).Where(x => x != null);
+
+ var urls = ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider.ProcessCompositeList(
+ depenencies,
+ cdfType,
+ new HttpContextWrapper(HttpContext.Current));
+
+ var result = new JArray();
+ foreach (var u in urls)
+ {
+ result.Add(u);
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/UI/JavaScript/CssInitialization.cs b/src/Umbraco.Web/UI/JavaScript/CssInitialization.cs
index b694f60a29..be92605cda 100644
--- a/src/Umbraco.Web/UI/JavaScript/CssInitialization.cs
+++ b/src/Umbraco.Web/UI/JavaScript/CssInitialization.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json.Linq;
+using ClientDependency.Core;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,7 +10,7 @@ using Umbraco.Core.Manifest;
namespace Umbraco.Web.UI.JavaScript
{
- internal class CssInitialization
+ internal class CssInitialization : AssetInitialization
{
private readonly ManifestParser _parser;
@@ -29,6 +30,9 @@ namespace Umbraco.Web.UI.JavaScript
ManifestParser.MergeJArrays(merged, m.StylesheetInitialize);
}
+ //now we can optimize if in release mode
+ merged = CheckIfReleaseAndOptimized(merged, ClientDependencyType.Css);
+
return ParseMain(merged);
}
diff --git a/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs b/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs
index 200bf6c4d2..389f50be00 100644
--- a/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs
+++ b/src/Umbraco.Web/UI/JavaScript/JsInitialization.cs
@@ -1,10 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
-using System.Web;
using ClientDependency.Core;
-using ClientDependency.Core.Config;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core.IO;
@@ -17,7 +14,7 @@ namespace Umbraco.Web.UI.JavaScript
/// Reads from all defined manifests and ensures that any of their initialization is output with the
/// main Umbraco initialization output.
///
- internal class JsInitialization
+ internal class JsInitialization : AssetInitialization
{
private readonly ManifestParser _parser;
@@ -54,55 +51,13 @@ namespace Umbraco.Web.UI.JavaScript
}
//now we can optimize if in release mode
- umbracoInit = CheckIfReleaseAndOptimized(umbracoInit);
+ umbracoInit = CheckIfReleaseAndOptimized(umbracoInit, ClientDependencyType.Javascript);
return ParseMain(
umbracoInit.ToString(),
IOHelper.ResolveUrl(SystemDirectories.Umbraco));
}
- ///
- /// This will check if we're in release mode, if so it will create a CDF URL to load them all in at once
- ///
- ///
- ///
- internal JArray CheckIfReleaseAndOptimized(JArray fileRefs)
- {
- if (HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled == false)
- {
- return GetOptimized(fileRefs);
- }
- return fileRefs;
- }
-
- internal JArray GetOptimized(JArray fileRefs)
- {
- var depenencies = fileRefs.Select(x =>
- {
- var asString = x.ToString();
- if (asString.StartsWith("/") == false)
- {
- if (Uri.IsWellFormedUriString(asString, UriKind.Relative))
- {
- var absolute = new Uri(HttpContext.Current.Request.Url, asString);
- return new JavascriptFile(absolute.AbsolutePath);
- }
- return null;
- }
- return new JavascriptFile(asString);
- }).Where(x => x != null);
-
- var urls = ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider.ProcessCompositeList(
- depenencies, ClientDependencyType.Javascript, new HttpContextWrapper(HttpContext.Current));
-
- var result = new JArray();
- foreach (var u in urls)
- {
- result.Add(u);
- }
- return result;
- }
-
///
/// Returns the default config as a JArray
///
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index bc480fa4f8..0be01640cc 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -417,6 +417,7 @@
+
ASPXCodeBehind