In order to deal with a especially complex web site project, we are looking into the possibility to host the Mkto form code in an external file, instead of adding the embed code in the web page.
Typically, the page will a contain a very short code:
<script src2="//info.domain.com/js/forms2/js/forms2.min.js" type="text/javascript"></script>
<form id="mktoForm_9999"></form>
<script>
var mktoFormID = 9999,
mktoMunchkinID = "999-XXX-999",
mktoDomain = "//info.domain.com";
</script>
<script src2="//info.domain.com/rs/999-XXX-999/images/ExternalEmbedCode.js" type="text/javascript"></script>
(I replaced scr with src2 in the <script> tags as the community editor removes the src from the <script> tags.)
Where ExternalEmbedCode.js contains all the form customized load code, starting with:
MktoForms2.loadForm(mktoDomain, mktoMunchkinID, mktoFormID, function(form) {...
The first tests seems to be working correctly.
Has anyone done such things? Any performance issue ? Any other thing to pay attention to ?
Thx for your help.
-Greg
Solved! Go to Solution.
It's totally fine, just an extra HTTP request. I do exactly that for complex projects. And remember, the external JS can't itself include tokens (but if you set a global variable in the main doc to a {{token}} first, that's taken care of).
It's totally fine, just an extra HTTP request. I do exactly that for complex projects. And remember, the external JS can't itself include tokens (but if you set a global variable in the main doc to a {{token}} first, that's taken care of).
Thx, as always, Sandy