January 30, 2015
Six Thousand Ways to Do All the Things
Small scripts in the text source of an Editable text web part (yikes)
Small scripts in a web part’s HTML envelope (not as much yikes, but still)
Small scripts in their own file in the content tree (?)
.js extension—good to know. I think it’s safe to say that the documentation doesn’t give us much guidance in terms of best practices. There are still so many ways we could manage our scripts! From this point, I'm going to try my best to explain a few patterns that have been helpful for me in achieving more consistent, maintainable script management.
Tip: You can cache your HTML on the server using Kentico's implementation of IIS output caching. Friendly advice: don't throw this switch when your site is in production.
Overwrite Kentico's jQuery
If you are developing on previous versions, you could potentially use the version of jQuery included in Kentico, but I've found that it's much safer (and more predictable) to go ahead and overwrite Kentico's jQuery after the
This will ensure that your version of jQuery overwrites Kentico's. The reason I recommend the beginning of the page rather than before the closing
</body> tag, is that it enables you to put small template related scripts inline after the related HTML.
Peace and Love,
Nate (for some stuff about me, click here)