DNN Blog

Oct 7

Posted by: Ian Robinson
10/7/2011 3:17 PM  RssIcon

Client side performance is something that a lot of us in the web world feel passionately about, and recently I’ve had the pleasure of working on some very exciting DNN enhancements in this area. I'll lead with a fun fact: number of CSS/JavaScript requests in DotNetNuke 6: twenty-two. Number in DotNetNuke 6.1: eight. But, before I give you all the details, let me set the “client side performance” stage.

Client side performance

Client side performance is important because most of the time loading a page is spent on downloading resources and putting them together in the browser. Applications such as DotNetNuke, and the servers they run on, are generally extremely fast at serving up files. However the number of files that are served (and the size of those files) determines how quickly the site will actually load for a user.

So, how can we improve? In general there are three key components for improving client side performance:

  1. Reduce the number of requests to the server.
  2. Reduce the size of the files being requested where possible.
  3. Serve only resources that are actually needed on a given page.

It is with these goals in mind that we introduce a new Client Resource Management API in DotNetNuke 6.1. This is an API that allows for registration of both JavaScript and CSS files and helps provide us with ways to deliver websites with fewer requests and a smaller overall payload.

The Client Resource Management API

The new API allows an extension developer to register CSS or JavaScript resources safely (automatically prevents duplicate registrations) and easily (can use the API directly in code or a user control in ASCX markup).

The API also manages the dynamic combination of files so that fewer server requests need to be made. It has an intelligent caching scheme to promote excellent performance, and it supports versioning as well, so that it’s easy to ensure that new files are incorporated when they’re added dynamically (such as when you install a new extension).

These are some very exciting capabilities that along with helping achieve performance goals, also allow for an easier and more intuitive development process.

Improved extension development workflow

One of the most compelling benefits of the new API is that it allows an extension developer to decouple “overloaded” CSS or JS files and break them out into smaller logical files (e.g. one for the layout/structure, one for fonts and colors, and one for the menu, etc.) and not have to worry about that nice separation during the development experience turn into extra performance overhead during the user’s experience of visiting the site. After all, each of those files will be combined appropriately.

As mentioned earlier, an important aspect of client side performance is only loading the resources that are actually needed, and if we’re structuring our CSS or JavaScript with a nice separation of concerns in mind from the beginning, we’re better able to register only those files that are needed in a given scenario.

In addition, JavaScript and CSS files can be automatically minified during the combination process, thereby alleviating the need for developers to maintain two different versions of files, or rely on their build process to create minified versions.

Additional technical details

If you’re interested in finding out more about the API and how it works, please visit our new Client Resource Management API page in the Wiki where the details are discussed in some depth. As of right now, the wiki will be the definitive place for information about the API.

Additionally, while it is not likely to do so, the API found in the beta is still subject to change prior to the final release.

We need your feedback!

The DNN 6.1 Beta is out, and we need your feedback. How can you help? Download and test the beta! Review the new API or test an upgrade in your development or staging environment. If you develop commercial or open source extensions, please install the DNN 6.1 beta and test your extension!

If you have a question or concern, please leave it here in the form of a comment. If you are testing the API and discover a bug or an oddity, please log it in Gemini and mention Client Resource Management in the ticket.

A couple of things to note while testing the new enhancements:

  1. If you're currently using the 40Fingers StyleHelper to unload files, I don't believe that will work any longer. I am investigating ways of enhancing this API with "unload" functionality for a future release, but the new API, at this stage, will frustrate any efforts to unload files and does not provide a new mechanism for unloading.
  2. Combining files may surface "dormant" issues with your CSS. For example, today I resolved an issue where a module.css file had an unclosed comment (i.e. /* .... ) at the end. While that is technically wrong, it doesn't cause any issues unless there is more CSS after it, and once we combined the files, there was. So double check your CSS comments! :)

Summary

The new enhancements in DNN 6.1 represent a very exciting first step in an improved client side performance story. DNN 6.1 represents getting the foundation layer (API) in place. We'll be taking advantage of the development work flows mentioned above to further refine the core framework's client side story over time, and as the community embraces the new API, we should see even large gains in real world sites. Enjoy!

10 comment(s) so far...


Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

I just read the wiki too and this is EXTREMELY exciting news! In all honesty, for me, even more exciting than the 6.0 release!

Many GREAT things coming through to 6.x!

By Jeff Blanks on   10/8/2011 10:29 AM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

@Jeff

Thanks!, I'm extremely excited as well! We just have a short window now to test upgrades and make sure the implementation is solid and then this stuff will be a reality.

So, if you (or anyone else) have the opportunity to test an upgrade or flex the new API at all over the next few days - please do so! I'd love to get any issues resolved ASAP and also would love to hear any constructive criticism on how to improve (although I probably won't be able to get any big enhancements into this release, but there's always the next one!)

Take care,

Ian

By Ian Robinson on   10/8/2011 10:33 AM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

@Jeff, this is one of the features coming to 6.x. There are many more exciting features that will continue making its way thorough the releases.

DotNetNuke 6.0 brings the solid foundation for all of us to continue this path and hope the community will embrace and take advantage of it.

By Cuong Dang on   10/8/2011 12:42 PM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

I always feel like the best features show up in the 1 or 2 point releases after a major release. Streamlining what DNN throws at the client is the best news I've heard in a long time.

We've stopped using a lot of "good" 3rd party modules because of their HTML/CSS output and/or inability to get control of it. Hopefully module developers will get on board with this movement swiftly. Thanks for the peek at 6.1 and giving us lots more to look forward to!

By Jeremy Farrance on   10/9/2011 2:41 PM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

Excellent write up. This is a very exciting new feature to the platform overall, and certainly a painful thing to deal with on the more trafficked websites out there.

@Jeremy: The only way some module vendors will change their mark-up is to demand it. Vote with your wallet, otherwise. ;)

By Will Strohl on   10/10/2011 7:08 PM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

Wow. This is great news! The client side aspect has long been a sore spot for me and I am extremely excited to see this new feature. Great work! Can't wait to see some metrics on the performance improvements.

What's next? Sprites?

By Jay Mathis on   10/12/2011 8:54 AM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

I am unclear - is this enabled/disabled on a site by site, page by page or module by modle basis? If I have some modules that take advantage of it and others that don't will it break the site?

By Lee Drake on   11/14/2011 12:56 PM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

Hey Lee,

This functionality is implemented at an application level. DNN 6.1 and up will use the new functionality without exception. However, the combination functionality can be turned on and off, as can the minification of CSS and JS. But everything is configured at an application level. A choice to use the API in one module and not in the next will be fine. There's nothing saying you need to start using the API - but it's there if you should like to.

Hope that helps,

Ian

By Ian Robinson on   11/14/2011 1:00 PM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

Hi Ian,
the enhancement certainly is a good approach but in my case I got a performance degradation because of some server bottleneck in ClientDependency.Core.dll, As I described on the forum: www.dotnetnuke.com/Resources/Forums/forumid/160/threadid/452284/scope/posts.aspx.

After Cathal’s suggestion I posted a bug log (support.dotnetnuke.com/issue/ViewIssue.aspx?id=20602&PROJID=2 )

I further continued with some research by checking the performance after commenting most of my code and css/js imports, but with no improvement.

In between I contacting Shannon Deminick, that addressed me on you:
“…I might not be the best resource for this specific issue as i don't really have DNN experience. A guy named Ian that works on the Dnn core implemented CDF in DNN who u may be able to chat to in order to debug into why this is happening. This lib had been around for some time now with no issues reported regarding this type of performance problem. That method call is probably the one that recursively scans all controls on the webforms hierarchy so at a guess perhaps DNN had a rather extensive one? Perhaps it's as simple as that and the method call could be optimized and/or cached …”

Well the first quick fix would be if you could tell me how to turn off the “Client Resource Management API”

If you would give me your email I would be pleased to send you my module without logic, for test purposes.

I would really appreciate your help,
Thank you,
Kristijan

By Kristijan Cerkvenic on   4/6/2012 6:33 AM
Gravatar

Re: Enhancements for working with JavaScript and CSS files in DNN 6.1

Hey Kristijan,

Sorry to hear you're having trouble. DNN uses ClientDependency framework to load nearly all framework level JS and CSS now, so there is no way to disable it. If there's an issue, the best way to move forward is to put an issiue in Gemini as Cathal suggested and move forward like that.

Thanks!

Ian

By Ian Robinson on   4/6/2012 6:37 AM
Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.