Developer forum

Forum » Feature requests » Change analytics script

Change analytics script

Rene Poulsen
Reply

Hi,

It would be really nice if the /Admin/Content/JsLib/dw/Analytics.js script could be changed. I think it should be placed in the footer and with the async and defer attributes (take a look at this artilce for more information: https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/)

If you change it to async and defer you'll probably have to changes som of the js, because the onload / DOMContentLoaded will be fired before the script is loaded.

The reason I would like this, is that with this very small change my page speed score (from pagespeed insights https://developers.google.com/speed/pagespeed/insights/) on one of our sites goes from 74 > 79 on mobile and from 96 > 98 on desktop. I know it may sound like a litlle increase, but as Google looks even more at performance, I think it would be worth it :-)

And one last thing: could you minify the script as well?

Let me know what you think.


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Rene

This is good input.

I will have someone take a look at it and see if there will be any implications. If not, we will implement it.

Thanks!

Nicolai

 
Rene Poulsen
Reply

Hi Niocalai,

That sounds awesome! ;-)

I've been trying to modify the script myself, but haven't had any luck yet. Gonna let you know if I get it working.

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Now that we are at it, would be nice to have a tag (Razor) that would allow us to add it to our compiler tool :)

Moreover, if it were to be a tag, we could place it in the footer, header, wherever we wanted.

 

One more thing... minify it :)

 

Best Regards,

Nuno Aguiar

 
Nicolai Høeg Pedersen
Reply

Of course.

Great input!

 
Rene Poulsen
Reply

Agree with Nuno - it would be nice to manually put the script whereever we want it. I would prefer it in the footer, but that doesn't mean others would :-)

 
Nicolai Høeg Pedersen
Reply

You can insert the tag Item.Area.OtherAnalyticsCode anywhere in a layout template. And then Dynamicweb will not add it...

 
Nuno Aguiar
Reply

Hi Nicolai,

 

We tested the tag in 8.5.1.14  with no luck. In what version is it available on?

 

Nuno

 
Nicolai Høeg Pedersen
Reply

Hi Nuno

I don't even understand my own post, so that is weird...

But you can add the Javascripts template tag in the bottom of your layoutfile and it will load there. The parser inserts that tag, but only if it is not present in the layout template already.

Nicolai

 
Nuno Aguiar
Reply

Hi Nicolai,

 

LOL. Sure I understand the parser and the overridding it.I am a bit confused myself though so I double checked.

 

We made a quick test in http://dwhotfix.fasteddie.dw-demo.com/ using 8.5.1.14 and it is not overriding. We have the tag output duplicated.

 

As for my tag request, I will do that in another feature request.

 

Thanks,

Nuno

 
Rene Poulsen
Reply

Any news regarding this one, Nicolai? Been bragging about bringing an average pagespeed score on both mobile and desktop above 90 on a site i'm currently working on. But it's only up there, because i disabled the statistics ;-)

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Rene

8.6.1 has a minified script and a deferred loading, see http://developer.dynamicweb.com/releases/dynamicweb-8-6-1.aspx#16579

BR Nicolai

Votes for this answer: 1
 
Rene Poulsen
Reply

Great!