This is a migrated thread and some comments may be shown as answers.

[Solved] ScriptRegistrar and CDN

2 Answers 248 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
nachid
Top achievements
Rank 1
nachid asked on 28 Mar 2010, 08:01 PM

The usage of CDN in ScriptRegistrar is still not clear to me
I have two differents cases to submit to your perspicacity.

A) local scripts referencing an external CDN
Let's suppose I am developping two small googlemap scripts:

  • myMap1.js
  • myMap2.js

Both reference an external CDN :http://www.google.com/jsapi
My frst idea was to create a group I named Google and add into it my two scripts
 
<add name="Google" defaultPath="~/Scripts/Google/" contentDeliveryNetworkUrl="http://www.google.com/jsapi">
 <items>
    <add source="myMap1.js"/>
    <add source="myMap2.js"/>
 </items>
 </add>
This did not work and produces only a link to http://www.google.com/jsapi


The second idea was to codify everything
 Html.Telerik().ScriptRegistrar().Scripts.AddGroup("myMaps", g=>g
                                                                 .Add("http://www.google.com/jsapi")
                                                                 .Add("/Google/myMap1.js")
                                                                 .Add("/Google/myMap1.js")
                                                   )

This also fails with '~/Scripts/http://www.google.com/jsapi' is not a valid virtual path.

So what's the best to handle this case?
Why there is no way to add an external CDN link with the need to create a group
I ended up creating two groups: one for the CDN and one for the two local scripts. (not really clean but...)

B) I guess this one is more common need.
A many, I usually  use Google CDN for my jQuery

I however did not find the way to put these tow common scripts in the same group

Thanks for your help

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 29 Mar 2010, 03:22 PM
Hello nachid rachid,

Indeed the current version does not allow defining web assets with full URL. I am sending an updated version which should allow this:

Html.Telerik().ScriptRegistrar().Scripts.AddGroup("myMaps", g=>g
                                                                 .Add("http://www.google.com/jsapi")
                                                                 .Add("/Google/myMap1.js")
                                                                 .Add("/Google/myMap1.js")
                                                   )

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
nachid
Top achievements
Rank 1
answered on 29 Mar 2010, 07:49 PM
Thank you so much for your quick answer

regards
Nachid
Tags
General Discussions
Asked by
nachid
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
nachid
Top achievements
Rank 1
Share this question
or