Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIdnn.dom.loadScript and PerformSubstitutiondnn.dom.loadScript and PerformSubstitution
Previous
 
Next
New Post
3/30/2008 11:28 PM
 

Hi Jon,

To dinamically load scripts on demand in my applications, I now use the dnn.dom.loadScript method  from dnn.js.
To make life more convenient I found this technique, which allows to load scripts, directly from embedded resources.

Here's one example of how this technique can be applied:
File:  dnn.js , line 1022

dnn.dom.loadScript(dnn.dom.getScriptPath() + 'dnn.scripts.js', null, oRef(aSrc, aText, callBack));

can be changed in:

dnn.dom.loadScript('<%=WebResource("dnn.scripts.js")%>', null, oRef(aSrc, aText, callBack));

Now,  to allow the url substitution, we need to set the required attribute for the dnn.js:

<Assembly: System.Web.UI.WebResource("dnn.js", "text/javascript", PerformSubstitution:=True)> 

Finally, we have to embed the dnn.scripts.js

<Assembly: System.Web.UI.WebResource("dnn.scripts.js", "text/javascript")> 

I hope this helps.

Regards 
Manzoni Fausto

 
New Post
3/31/2008 8:59 PM
 

Interesting post, however, the substutition will not work for the dnn.js file as it is not interpreted by asp.net.  However, if we wanted to we could send the value down via the ClientAPI's setVar.  

The best and most performant mode of adding script references is to have an external file reference as this puts no load on the server (ASP.NET process).  This is the default mode that DNN will ship in and will be the recommended way. 

Embedded scripts are nice in that they allow a developer to simply add a reference to a dll to integrate with their project and not need to worry about copying one or more scripts as well.  With dnn, we have the luxury of being able to include the externals without any additional overhead (you already need a lot of files to get dnn to run, whats a few more...)

 


 
New Post
4/1/2008 3:14 AM
 

What you say is correct, although I do not know exactly the impact that the use of embedded scripts can have in terms of performance,(there are a number of applications that utilize embedded scripts).

However, there is another performance issue that you might consider, that is the number of HTTPRequest required to render the page, as documented here.
In DNN each module can have its own CSS and more than one javascript file,(especially an ajax module).
At the end a page can require a lot of external files to be rendered.
Adding script references through the Script Manager, gives the possibility to combine all script references,(present in Its collection) in a single compressed file, using an HttpHandler.

An example of this technique, the ToolkitScriptManager, can be found in the AjaxControlToolKit.
I use a similar technique for css added through CSS placeholder.
I know that this may not be suitable for all possible scenarios but, in my case, the performance is significantly improved.

"the substutition will not work for the dnn.js file as it is not interpreted by asp.net."
In the ClientApi beta it work.

 
New Post
4/3/2008 8:28 AM
 

Yes, I have considered the idea of combining the scripts before.  See this blog from last June.

http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1469/Default.aspx


 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIdnn.dom.loadScript and PerformSubstitutiondnn.dom.loadScript and PerformSubstitution


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out