Avoid duplicate loading of Forms2.js? | Community
Skip to main content
September 18, 2015
Question

Avoid duplicate loading of Forms2.js?

  • September 18, 2015
  • 2 replies
  • 4223 views

Hi,

We are only calling forms2.js and munchkin.js once in our base code, but on page inspection on dev tools under network, there seems to be two insertions of forms2.js and two insertions of munchkin.js.

There's the version that we included (forms2.js?ver=4.2.5), and a minified version (forms2.min.js) called in an XDframe. Why does Marketo not serve the minified version to begin with?

Any way to avoid duplicate loading of scripts?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

July 21, 2016

Having the same issue here.

Including "app-sj01.marketo.com/js/forms2/js/forms2.min.js" once but "forms2.min.js" is being requested twice on the page load.

After a quick I investigation, i found that the first request for "forms2.min.js" is being made from the page which is the intention but the second request is being made by a Marketo source which is "app-sj01.marketo.com/index.php/form/XDFrame".

How can I prevent this duplicate forms2.min.js requests?

Any solution to this? Anyone?

SanfordWhiteman
Level 10
July 21, 2016

You cannot.  The script cannot be shared between the main document and the xdframe due to age-old browser restrictions.  It needs to be loaded in each context. 

Level 2
February 6, 2017

Dealing with this issue today as we are trying to get two forms loading on the same page and loading forms2.min.js multiple times is causing each form to show up multiple times.

Since we cannot share the script across multiple elements does this essentially mean there is a hard limit of one form per page?

SanfordWhiteman
Level 10
February 6, 2017

The inner load of forms2.min.js in the cross-domain frame is not causing this problem. It can't be, because the main document only sees the main document's scope.

And you don't have to load forms2.js twice in the main document to have 2 forms.

If you post a sample URL I can tell you what's really happening, but I doubt it's what you think.

Level 2
February 6, 2017

Thanks Sanford, since you ruled that out for me I took another look and as you stated the issue was unrelated.

Our website is in development an still has a lot of placeholder forms/sections. I believe the issue was related to the two placeholder forms being the same form ID. Once I replaced one form with a different ID the issue seemed to resolve itself.