PnP Javascript embedding for a lot of site collections

Copper Contributor

Dear Techcommunity,

 

I managed to embed javascript to one of my sites using the Core.EmbedJavascriptJSOM sample.

I would like to add the same javascript to all of my site collections inside my tenant.

 

Could you please advise, what would be the best approach to do this?

 

Thanks in advance,

Best wishes,

Zoltán

1 Reply
As an idea, I'd create a PnP Template, with a CustomAction to load the JS file, and a File node deploying the JS file into the Style library. Then you could use some CSOM code to iterate to all your site collections (here is a sample with PS: https://gallery.technet.microsoft.com/office/How-to-get-all-the-tenant-2999c21b), and for each Web object, you can call the PnP PowerShell command: Apply-PnPProvisioningTemplate (https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/ApplyPnPProvisioningTemplate....)

Also, have you consider to share the same JS file? I mean to use a CDN with your JS file, and point the CustomAction to that shared URL.