官术网_书友最值得收藏!

SharePoint Online--add-ins and client-side scripts

In addition to add-ins, developers often need to drop small functionality and bits of features to individual pages within SharePoint sites. A common approach is to add a Script Editor Web Part on a page and drop a piece of JavaScript and/or HTML within the page. This is a very simple approach but can be both powerful and troublesome in the long run.

The benefits of using a Script Editor Web Part (SEWP) is that it's very easy to add as an ad-hoc solution when in a meeting with the site owner and simply code on-the-fly whatever is needed. This is assuming the developer is quite capable and fluent with JavaScript and the SharePoint APIs.

Adding a SEWP on a page allows developers to write JavaScript through the browser and save it into SharePoint Online's own database:

Upon page load, the script is executed and the user gets the result of the preceding code in a popup since the sample is using the classic JavaScript alert() message box:

The downside is that pages tend to become littered with all sorts of small JavaScript tidbits that no-one can keep track of. One piece of code could reference an external library that has a locally stored copy of a SharePoint document library, while another piece of code (even on the same page!) might reference the very same external library but a different version through a public CDN URI. Thus, the payload for a user loading the page would be at least double, as the client browser would need to resolve both external frameworks, load the payload, and figure out which version to use and when. Imagine having hundreds of sites, thousands of pages, with customizations using the SEWP-approach on five percent of all pages. You very quickly run into performance and supportability issues, as well as troubleshooting errors that are not obvious as frameworks are not referenced in a proper manner.

主站蜘蛛池模板: 平和县| 曲水县| 忻州市| 芷江| 五峰| 团风县| 江西省| 呼玛县| 安乡县| 兴山县| 嘉祥县| 香河县| 西畴县| 濮阳县| 太谷县| 本溪| 内江市| 镇平县| 平利县| 翁源县| 怀柔区| 钟山县| 景东| 新安县| 玛沁县| 慈利县| 花莲市| 昌邑市| 获嘉县| 河池市| 大姚县| 辽阳县| 阳信县| 北流市| 建水县| 碌曲县| 大田县| 普陀区| 西乌珠穆沁旗| 佛坪县| 留坝县|