The amount of javascript blocks in pages

Posted by Community Admin on 04-Aug-2018 12:28

The amount of javascript blocks in pages

All Replies

Posted by Community Admin on 29-Jun-2011 00:00

I'm new to Sitefinity as a front-end developer and my web development company is in the process of deciding whether to use Sitefinity as the default CMS for all future clients. One major issue I have with Sitefinity is the amount of javascript code blocks it outputs in web pages. In our current example page (which unfortunately I can't share here) there's several inline code blocks (script tags early in the body area of the html) and several externally referenced ones aswell. The total size is not a huge problem (around 50Kb in our example), but I fear for the rendering speed of the pages. Both inline script blocks and external references (http requests) have a negative effect on load times. Besides that it's an issue of code neatness.

My questions:

- Is there anything a developer can do to reduce the amount of javascript generated?
- Are all these scripts necessary? The page does not use any Telerik controls, no drop down menu or anything. Only a few custom scripts which we've placed in the masterpage ourselves (those are the only ones we were hoping to see).

Any help, explanation or advice appreciated, and my apologies if this has been brought up before.

Posted by Community Admin on 01-Jul-2011 00:00

Hi Geert,

If you are using jQuery in your scripts they might get in conflict with some Sitefinity jQuery. You may try to resolve the conflicts with noConflict().

1)The default javascript generated is needed for Sitefinity page as it is not showing static content. Some of this javascript can be reduced by disabling Browse and Edit functionality. To disable it go to Administration -> Settings-> Advanced-> Pages  and set EnableBrowseAndEdit to False this will remove it from the last javascript block containing the loadHandler. the default scripts on an empty page should not slow your performance as with them the page is requested in about 600ms when deployed in IIS( without images that have not been already cached).
2) The scripts added are necessary. They can be reviewed at Administration -> Settings-> Advanced-> Pages-> Script manager-> Script References. The script that is always loaded is the loadHandler and Telerik.Web.UI.WebResource.axd which contains the scripts for widgets and also provides script combining to reduce the server calls for the necessary scripts and puts them all in a single file which is cashed and they will not have to be requested again. This happens when the page is requested for first time. If you remove a script from script references Sitefinity breaks. You can test deploying a project in IIS as the integreted web server in Sitefinity is not as fast as IIS and observe the load these scripts cause. You can do Asynchronous Javascript loading for your script to improve performance.

Greetings,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 17-Jun-2016 00:00

Our home page uses javascript for a slider.  How can I load this Async.  There is no option in the JavaScript widget?

Posted by Community Admin on 22-Jun-2016 00:00

Hi David. 

If you are using Feather and JavaScript widget. And you need async attribute

I can suggest you to duplicate all code from existing widget (github.com/.../JavaScriptController.cs) and just add async attribute inside template. And, of course, rename it for example "JavaScript Async" 

Posted by Community Admin on 28-Jun-2016 00:00

We are currently using the normal sitefinity widgets.

This thread is closed