4

Our client wants us to improve the performance of the solution and used https://developers.google.com/speed/pagespeed/insights/ to test it. Now "Google Insights" says:

Your page has 2 blocking script resources. This causes a delay in rendering your page. Remove render-blocking JavaScript: https://www.example.com/api/utils/libs/jsnlog.min.js https://www.example.com/layouts/system/VisitorIdentification.js

We're loading these two files with the standard Sitecore Razor commands:

@Sitecore.Diagnostics.ClientLog.RenderClientLogConfiguration() and @Html.Sitecore().VisitorIdentification()

So there are a few questions here.

  1. Does it even make sense to asynchronously load those two java script files or would it break something?
  2. If it makes sense, how would you do it?

To change the VisitorIdentification.js we could edit \layouts\system\VisitorIdentification.ascx.

But I'm not sure how to do that with jsnlog.min.js. As you can see we already adjusted the path to the file itself, but that's all happening in the configs.

3
  • 1
    You would not gain much from this. VisitorIdentification.js is a 3kb file that is requested only on the first page load of a session. jsnlog.min.js is also relatively small (8kb). Logically, a logging library should be loaded before all other scripts, so deferring its execution is not ideal. Note that if you're not using xDB, you could remove the VisitorIdentification tag altogether since it serves as robot detection for analytics.
    – maz
    Apr 3, 2017 at 17:10
  • Thanks. Yes we are using xDB. So performance wise it doesn't make sense to optimize these files. How about Google Ranking? Is that effected?
    – z00mable
    Apr 4, 2017 at 6:53
  • 2
    I did a test with a simple page and the overall difference in total page response/rendering time was negligible. Therefore I would not expect an impact on search rankings. Remember that Google recommend that their own tracking scripts (e.g. Analytics and GTM) be put within the <head></head> tags and not be deferred. It wouldn't make much sense then to penalize sites that use this practice.
    – maz
    Apr 4, 2017 at 13:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.