Yammer embed feed is often added to the front page of the company intranet in Sharepoint. From one side it adds value to customers as users may see corporate feed together with other important content on the same page. From other side it adds drawback: increase of the total page load time (by total time I mean time needed for both server and client side components. Yammer adds more time to the client part). We measured that Yammers adds ~3-4 seconds to the scripting part of the page load time. Is there a way to improve situation?
Let’s check how Yammer embed feed is added on the page. In most cases it is added via Content editor web part and the following code:
1: <!DOCTYPE HTML>
2: <html>
3: <head></head>
4: <body>
5: <script type="text/javascript"
6: src="https://c64.assets-yammer.com/assets/platform_embed.js"></script>1:
2: <div id="embedded-feed" style="height:1000px;width:400px;"></div>3: <script>
4: yam.connect.embedFeed({"config": { "header": false },5: "container": "#embedded-feed",6: network: 'example.com' });7: $(window).load(function () {8: $('.frontpage #embedded-feed').width('100%');9: });
10:
</script>
7: </body>
8: </html>
As you can see script is loaded from Yammer CDN https://c64.assets-yammer.com/assets/platform_embed.js. So the first thing I tried was to move this script to the Sharepoint doclib, but it didn’t give visible results (internally this script loads a lot of other scripts and css files from CDN and also adds iframe dynamically).
After that I tried to use another approach which gave some results. First of all create new page (e.g. yammer.aspx) in Pages doclib and detach it from Page layout via Sharepoint Designer. After that remove all code from there and add only Yammer code shown above.
Then we need to modify the page where we show embed Yammer feed: instead of Content editor web part which was used for Yammer initially we will use Page viewer web part and configure it to use newly created page yammer.aspx as a source (that’s why we needed to detach this page from page layout – it should not contain any UI elements like headers, navigation, etc. It should only contain Yammer widget). I.e. after that page will look the same, but technically there is difference how Yammer is shown there. Now Yammer is shown in sub page via iframe in separate http request and its scripts not affect load of basic page. At least for us after that our testing showed that scripting time was reduced on ~2 seconds. Hope that information will be helpful for you.
No comments:
Post a Comment