Add-PnPJavaScriptLink

Adds a link to a JavaScript file to a web or sitecollection

Syntax

Add-PnPJavaScriptLink
   -Name <String>
                        -Url <String[]>
                        [-Sequence <Int>]
                        [-Scope <CustomActionScope>]
                        [-Web <WebPipeBind>]
                        [-Connection <SPOnlineConnection>]

Description

Creates a custom action that refers to a JavaScript file

Examples

------------------EXAMPLE 1------------------

Add-PnPJavaScriptLink -Name jQuery -Url https://code.jquery.com/jquery.min.js -Sequence 9999 -Scope Site

Injects a reference to the latest v1 series jQuery library to all pages within the current site collection under the name jQuery and at order 9999

------------------EXAMPLE 2------------------

Add-PnPJavaScriptLink -Name jQuery -Url https://code.jquery.com/jquery.min.js

Injects a reference to the latest v1 series jQuery library to all pages within the current web under the name jQuery

Parameters

-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Name

Name under which to register the JavaScriptLink

Type:String
Aliases:Key
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Scope

Defines if this JavaScript file will be injected to every page within the current site collection or web. All is not allowed in for this command. Default is web.

Type:CustomActionScope
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Sequence

Sequence of this JavaScript being injected. Use when you have a specific sequence with which to have JavaScript files being added to the page. I.e. jQuery library first and then jQueryUI.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Url

URL to the JavaScript file to inject

Type:String[]
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type:WebPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False