Google Analytics

Move script from inline no document to external file - Google Analytics

Move script from inline no document to external file

by energyuser » Thu Oct 30, 2014 7:08 pm

Having the Google Analytics code wrapped inside the <script>// ...</script> tags looks kind of ugly, because there aren't any other inline scripts in the code. Isn't this a violation of the coding guidelines? Probably could have an external file in the extension directory and link to it with <script src=""... and inside that file we can add the code and a PHP variable that will have it's value updated every time a change on the Google Analytics ID is made from the ACP.
energyuser
Registered User
Posts: 68
Joined: Fri May 03, 2013 4:56 pm
Contact:

Re: Move script from inline no document to external file

by MattF » Thu Oct 30, 2014 7:27 pm

It has to be inline code. It contains template variables. It is asynchronous code and must run ASAP and not wait to be loaded late as an http request. It is not a violation of coding guidelines. It doesn't matter if it looks ugly, it's html page source code.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5861
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Move script from inline no document to external file

by energyuser » Thu Oct 30, 2014 7:37 pm

Well, it won't have defer or async so I suspect it'll be loaded ASAP?
energyuser
Registered User
Posts: 68
Joined: Fri May 03, 2013 4:56 pm
Contact:

Re: Move script from inline no document to external file

by MattF » Thu Oct 30, 2014 7:41 pm

This is the way it is supposed to be done. It is exactly to the specification of Google. And that is the point of this extension.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5861
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Move script from inline no document to external file

by MattF » Thu Oct 30, 2014 7:50 pm

Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5861
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact: