ResourceLinks Clarification
ResourceLinks is handy for only loading a script once right?
1) So is that also the case if you load via embedded resource, AND relative pathing
2) Does relative pathing even work to only load it once?
3) Can you allow .less to be served from the control as well?
Hi Steve,
All of the ways that you described load the resources once, until you edit them or rebuild the solution of your project. This depends on the StaticExpiration property of the browser. If it is enabled, then no matter how you load the scripts, they will always be cached in the browser, until they have been edited.
As for the .less resources, I don't think that this would be possible as the control is internally built to load only the specified extensions.
Hey Svetoslav,
" As for the .less resources, I don't think that this would be possible
as the control is internally built to load only the specified
extensions."
Yeah that's what I mean...can you change the allowed extensions on the control to allow LESS? :)
Hi Steve,
I just checked how the control works and it internally checks for the resource type and returns the specific type of resource. It all happens in this method:
protected
virtual
WebResourceType GetResourceType(
string
resourceName)
if
(
string
.IsNullOrEmpty(resourceName))
throw
new
InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameNotDefined);
if
(resourceName.IndexOf(
"."
, StringComparison.OrdinalIgnoreCase) == -1)
throw
new
InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameMissingExtension);
string
resourceExtension = resourceName.Substring(resourceName.LastIndexOf(
"."
, StringComparison.OrdinalIgnoreCase));
if
(!allowedExtensions.Contains(resourceExtension.ToLowerInvariant()))
throw
new
InvalidOperationException(Res.Get<ErrorMessages>().ResourceLink_ResourceNameInvalidExtension);
string
extension = resourceName.Substring(resourceName.LastIndexOf(
"."
, StringComparison.OrdinalIgnoreCase));
switch
(extension.ToLower())
case
".css"
:
return
WebResourceType.StyleSheet;
case
".js"
:
return
WebResourceType.JavaScript;
case
".jpg"
:
case
".jpeg"
:
case
".gif"
:
case
".png"
:
return
WebResourceType.Image;
return
WebResourceType.StyleSheet;
if
(!allowedExtensions.Contains...
) uses an internal List (allowedExtensions) which you won't be able to change, so you may need to change the whole logic for that particular method. However, all in all, I don't think this will work very well, as it will be too hacky.
All the best,Can you either just make that change in the code for 5.0, or just put in a PITS to add
case
".less"
:
return
WebResourceType.StyleSheet;
Hello,
Hi,
I logged in a feature request for the .less resources. Here's the PITS issue you can follow:
http://www.telerik.com/support/pits.aspx#/public/sitefinity/10026
As for the versioning, this is a reasonable suggestion, so we will discuss it internally and see if it can be implemented in Sitefinity. Thanks.