Presentation is loading. Please wait.

Presentation is loading. Please wait.

Working with different JavaScript frameworks and libraries

Similar presentations


Presentation on theme: "Working with different JavaScript frameworks and libraries"— Presentation transcript:

1 Working with different JavaScript frameworks and libraries
Different options to load JavaScript libraries

2 Agenda Install JavaScript libraries
Configure JavaScript library bundling Use the JavaScript libraries in a web part Q&A

3 Install JavaScript libraries and type definitions
SharePoint Install JavaScript libraries and type definitions Install the npm packages for the libraries you need in your web part Install the type definitions for the libraries These commands install the type definitions into the folder. Some libraries, such as Moment, provide their own type definitions, so you don't need to install them > npm i jquery --save > npm i jqueryui --save > npm i chartist --save > npm i moment --save > npm -D > npm -D > npm -D © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 How dependencies are bundled
SharePoint How dependencies are bundled Any dependencies you add are bundled by default You may exclude dependencies from the web part bundle config.json configures the web part bundle Entries region contains default bundle information One entry exists for each web part in the solution By default, any dependencies you add are bundled into the web part bundle. In some cases, this is not ideal. You can choose to unbundle these dependencies from the web part bundle. In Visual Studio Code, open the file config\config.json. The config\config.json file contains information about your bundle(s) and any external dependencies. The entries region contains the default bundle information. In this case, the jQuery web part bundle. When you add more web parts to your solution, you will see one entry per web part. "entries": [ { "entry": "./lib/webparts/helloWorldJQuery/HelloWorldJQueryWebPart.js", "manifest": "./src/webparts/helloWorldJQuery/HelloWorldJQueryWebPart.manifest.json", "outputPath": "./dist/hello-world-j- query.bundle.js" } ] © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Excluding dependencies from the default web part bundle
SharePoint Excluding dependencies from the default web part bundle The externals section contains the libraries that are not bundled with the default bundle To exclude a dependency, add it to the externals section The externals section contains the libraries that are not bundled with the default bundle. "externals": {} Exclude jQuery from the default bundle, by adding the jQuery module to the externals section. "jquery":"node_modules/jquery/dist/jquery.min.js" © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Bundling impact Avoid bundling when not needed
SharePoint Bundling impact Avoid bundling when not needed Some libraries are enormous Example: moment.js used in lab exercise k (per web part) added to the bundle Use the WebPack visualizer to inspect the web part bundle © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 Import libraries into a web part
Use import statements in the web part class

8 Load CSS used by library components
Use require statements in the web part class

9 Use the libraries in the web part class
SharePoint Use the libraries in the web part class © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 DEMO Different options to load JavaScript libraries SharePoint
Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual. © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Summary Install JavaScript libraries
Configure JavaScript library bundling Use the JavaScript libraries in a web part Q&A

12 Sharing is caring… http://aka.ms/SharePointPnP
Code samples and solutions Reusable components Guidance documentation Monthly community calls SharePoint Framework SharePoint add-ins Microsoft Graph Office 365 APIs

13 11/28/2018 Q&A © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 11/28/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Working with different JavaScript frameworks and libraries"

Similar presentations


Ads by Google