Optimize
4.9K members online now
4.9K members online now
Everything you need to know about setting up Optimize including creating your account and container, linking to Google Analytics and how to tag your site.
Guide Me
star_border
Reply

Optimize Script slow down the page.

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi guys,

 

Just wondering if anyone here experiences slow page load when you implement 2 scripts from Optimize ( the hidden page tag and the JS tag)???

 

What is a way to improve the speed of the page?

 

Regards,

1 Expert replyverified_user

Optimize Script slow down the page.

Google Employee
# 2
Google Employee

Can you give some more details on how slower did your page become?

 

The first thing that you may want to try, is to follow the instructions (if possible) and add the snippets, inline on the very top of the head (in correct order: page hiding goes first).

 

By doing that, the browser will download them together with your CSS files and you should have 0 or a negligible overhead.

 

If you tried to customize the default snippets or implement them in a non default manner (not inline at top of head), there may be a mistake which is causing the delay.

 

Can you give your page url or your container ID?

Optimize Script slow down the page.

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Dimitris,

Sorry for the late reply.

 

We found out why the page actually load slower than usual as our web server using the Spring framework.

I give it a try again!

 

Thank you!

 

Optimize Script slow down the page.

[ Edited ]
Follower ✭ ☆ ☆
# 4
Follower ✭ ☆ ☆

I had a complaint from a client about Page Optimising Snippet slowing down their pageloads.  It was quite noticeable and I stared at a blank page for a few seconds.  They even sent me a comparison video with before and after.  Before page optimizing snippet the page started rendering at 2.4 seconds.  After, it started rendering at 6.2.

 

Below is the location of the code, which is quite high up in the <head> section before any CSS or JS files (I've changed the IDs of the GTM container for this post, in case you think that's the issue):

 

<!DOCTYPE html>
 <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
 <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
 <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
 <!--[if lt IE 9]> <html class="old-ie" lang="en"> <!![endif]-->
 <!--[if gte IE 9|!(IE)]><!-->
 <html lang="en">
 <!--<![endif]-->
 <head id="ctl00_head"><meta http-equiv="X-UA-Compatiblecontent="IE=edge" /><link rel="canonicalhref="website.com" /><meta name="objectcontent="menuitem" /><meta name="robotscontent="NOODP,NOYDIR" /><meta property="og:imagecontent="website.com/am_logo_fb.png" /><meta property="og:titlecontent="Home" /><meta property="og:descriptioncontent="" /><meta property="og:urlcontent="website.com/home" /><meta property="og:site_namecontent="Site" /><meta property="og:typecontent="website" />
 <!-- Page hiding snippet (recommended) -->
 <style>.async-hide { opacity: 0 !important} </style><script>(function (a, s, y, n, c, h, i, d, e) {s.className += ' ' + y; h.start = 1 * new Date;h.end = i = function () { s.className = s.className.replace(RegExp(' ?' + y), '') };(a[n] = a[n] || []).hide = h; setTimeout(function () { i(); h.end = null }, c); h.timeout = c;})(window, document.documentElement, 'async-hide', 'dataLayer', 4000,{ 'GTM-IDCODE': true });</script>
 <!-- Google Tag Manager -->
 <script>(function (w, d, s, l, i) {w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'}); var f = d.getElementsByTagName(s)[0],j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src='https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);})(window, document, 'script', 'dataLayer', 'GTM-IDCODE');</script>
 <!-- End Google Tag Manager -->

Optimize Script slow down the page.

Google Employee
# 5
Google Employee

Yes this sounds, very much as the problem described in this post and I believe that there will be a new diagnostic message in Optimize for this problem soon.

 

I can't see anything wrong in the section of the code that you have posted but an easy to test is this: open the page in question on chrome and open the developer tools.

 

Then just type in dataLayer.hide.

 

If you get back "undefined" then the dataLayer variable must be redefined somewhere below in the page.

 

See this page for a detailed human friendly explanation of the page hiding snippet:

https://developers.google.com/optimize/

 

It basically defines a function dataLayer.hide.end, which - if exists - is called by the Optimize and GTM containers as soon as they load. If dataLayer is overridden and containers are not been able to access that function, they will not be able to 'unhide' the page, which will remain blank until the timeout occurs.

 

 

Re: Optimize Script slow down the page.

Follower ✭ ☆ ☆
# 6
Follower ✭ ☆ ☆
Actually, I think I've identified my particular issue. The GTM container
has just been added to the site and had no tags in it so it was returning a
404 error for gtm.js. Everything is now looking much snappier :-) !!

I don't think the page-hiding snippet was the issue. The dataLayer.hide
did not return undefined either:

dataLayer.hide

1. Object {GTM-K9LBT2N: false, start: 1502417718410, end: null, timeout:
4000}
1. GTM-IDCODE:false
2. end:null
3. start:1502417718410
4. timeout:4000
5. __proto__Smiley Surprisedbject

Optimize Script slow down the page.

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Nick, 

I have the same problem where pages are blank for a couple seconds.  Can I hire you to fix this?