Showing posts with label CDN. Show all posts
Showing posts with label CDN. Show all posts

Wednesday 1 November 2017

Using a CDN for Custom User Actions

Problem:  I need to inject JavaScript into a couple of hundred thousand site collections and subsites using a Custom User Action.  I want to use a CDN.  Governance will not let me add to the layouts folder on the WFE's.  Using a CDN for a CUA is causing the blank page.

Initial Hypothesis:  I don't want to deploy the same JS file hundreds of thousands of times into the local site collections.  As updating and storage are crazy.  I want a CDN like behaviour, and the closest I can get is to modify the hive directory on each SharePoint on-prem. farm that allows me to reference the JS.  I do have several farms and IT governance won't let me modify the WFE's.

Tobias Lekman has an excellent comprehensive overview of the CUA issue:
https://blog.lekman.com/2013/01/scriptlink-registration-in-sharepoint.html

Doing the usual testing, bizarrely I can use anonymous https://radimaging.sharepoint.com/_layouts/15/guestaccess.aspx?docid=55529eccf4555d698555cb26108fb555&authkey=555-6M9555zF555g555 for my CUA JS file.
When I allow external access on my personal public O365 E3 tenant, I can use this URL, the CUA works perfectly.  My client does not have an Office 365 external public tenant I can use, so an Akamai (or another CDN)CDN and fake the validation.  It's either SP URL validated, or I need to load it differently if I want to use a CDN.  I used an Akamai CDN and added /_layouts/15/ into the URL using folders, and the CDN started working for my CUA. e.g. https://cdn.domain.com/sharepoint/_layouts/15/cuatest.js

Possible Resolution:
  1. Local Site Collection uploaded files
  2. CDN assuming the JS location has: 

Wednesday 6 October 2010

jQuery intellisense

Problem: jQuery is pretty useful and I'm not great at creating it.
Hypothesis: I am using jQuery version jquery-1.4.2.js to get intellisence I need to reference jquery-1.4.1-vsdoc.js, this should be removed at deployment.  You can reference the Visual Studio jQuery Intellesense file (jquery-1.4.1-vsdoc.js) either from microsoft's CDN or deploy locally to the 14 hive.

References:
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
http://www.devcurry.com/2010/02/visual-studio-jquery-intellisense-over.html

Samples:
Get the input from a multiline text box/Textarea
var existingComments = $("[id*='txtComments']").val();
Explaination - txt comments is an text box namely: asp:TextBox runat="server" ID="txtCommentsAmend" TextMode="MultiLine".  val() gets the inner html/content.
Append additional data to the text box
$("[id*='txtCommentsAmend']").html(existingComments + 'more info');
Explaination - using the previous example variable append additional text in the textbox.