In December 2013, version 7.2 of the DNN Platform was released, which included a new type of extension, the JavaScript Library. At Engage, we've found this to be very useful to us in many scenarios, and we've been investing in creating a solid body of libraries, but I don't think that many other developers or theme designers are aware of it and how they can make use of it.
JavaScript Library packages are deceptively simple. At one level, they just package a single JavaScript file. However, the existence of this package provides a number of straightforward benefits:
- DNN allows multiple versions of a JavaScript Library package to be installed, so different extensions can request different versions.
- However, if different extensions on the same page request different versions, the highest version wins, which reduces script conflicts.
- The library defines metadata about the JavaScript library, such as where in the document it is included (e.g. html5shiv is automatically included in the page's
<head>
, but most other libraries can wait until the end of the </form>
, speeding up initial rendering time)
- Additionally, a CDN URL can be included with a JavaScript package, allowing a host administrator to flip a switch and benefit from globally distributed versions of the script (this also provides the benefit of domain sharding). Along with this, a JavaScript expression to test is also included, so that DNN can fallback to the local version of the script if the CDN is inaccessible.
So, how do I get these wonderful benefits in my DNN website? The first step is to check out the Usage section of the wiki article on JavaScript Libraries, and see what it looks like to use JavaScript Libraries in your own extensions. Once you're ready to use them, you'll need to have them available to you. Engage has created a handful of packages for libraries that we're using (see them on the Forge), but I'm sure that this doesn't contain every library that you might use on your site or in your extensions. If you grab a copy of our JavaScript Libraries repository on GitHub, there is a PowerShell script in there to generate a package based on information from Bower. Reach out to me on Twitter if you're interested in contributing more packages.
The real benefit of JavaScript libraries starts to come when they're used by more and more components in a website. Let me or other folks working on DNN or in the MVP group know what you need to make better use of features like this that DNN provides, so we can create the best platform for your web applications. If you're interested in helping out, the README in Engage's GitHub repository has a Roadmap section with some ideas.