7

Working on an overview of all possibilities of adding JavaScript.

Can someone confirm Custom Actions run **after JSLinks**

By execution order:

Page Scripts

using <script> tags or scriptlink includes.

MasterPage

The MasterPage executes on every SharePoint page.

On Office365/SharePoint Online this method is discouraged by Microsoft (so any Cloud functionalty pushed by Microsoft does not conflict with your code

Page

Same construct as MasterPages, scripts are only loaded on one page

Edit ASPX page in SharePoint Designer (or any text editor)

JSLink injections on WebParts, Views, Forms, Fields

JSLink connection to CSR JS files (but can be any JS file)

SharePoint Online allows for absolute URLs, OnPrem requires URLs with ~token

Calculated Column (View)

(Like the CEWP) Executes JavaScript while the page is loading

Custom Actions

WebParts on page

CEWP

<script> content

The code is executed while the page is loading, so put the WebPart at the bottom of the page or use jQuery ready function or SharePoints _spBodyOnloadFunctionNames

Without content IN the WebPart, the title can link to a JavaScript in a Library

SEWP

Browser

These scripts (Great for Admin tasks) are not part of SharePoint but can run in the Browser (for the current Browser/User only)

Extension

Browser Extensions (Chrome & FireFox) must be installed

  • (Chrome Browser Extension) Cisar
    Edit CSR files (and create JSLinks) with Live Updating

  • (Chrome Browser Extension) Chrome SP Editor
    Edit SharePoint files, add ScriptLinks to SiteCollection/Webs, manage Web Property Bag

These are powerfull ones, executing script automatically on pages

Console (manual)

Chrome Snippets (manual)

Allow for editting JavaScript against the current SharePoint context.

https://developers.google.com/web/tools/chrome-devtools/debug/snippets/?hl=en

Bookmarklet (manual)

  • BookMarklet iCSR Link Manager
    update JSLink settings on WebParts & Views, deploy JS files to Style Library

J1 J5 JW

0

It's actually the opposite; I can confirm that custom actions run before jslink. It works out well that this is true. If you have the same dependency on a number of jslink scripts, you can load it once as a site or web custom action.

The alternative is to set all of your jslink to "~sitecollection/<path>/jquery.js|~sitecollection/<path>/yourscript.js" which gets pretty messy as dependencies grow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.