add code in index.html

0 favourites
  • 8 posts
From the Asset Store
Add SubRip (SRT) subtitles to your videos in Construct 3
  • Is it possible to add some code directly in the exported index.html via an existing plugin ? If not, is it possible to do this directly with doing a plugin ?

  • What do you need to add? It may be possible depending on what you want.

  • I would like call an API as

    <script type="text/javascript" src="http://***API_URL***"></script>

  • Most APIs have an asynchronous option which is better since it improves loading times - you can dynamically create a script in your plugin's startup code and usually it then makes a callback to say it's loaded. That's what the Facebook plugin does, it loads Facebook's script dynamically without adding any script tag to the HTML page.

    However if you're stuck with an API that doesn't support that, there's an undocumented feature that lets you do that - add a dependency property to GetPluginSettings() in edittime.js like this:

    "dependency": "myfile.js"

    This will then add a script tag for "myfile.js" in the HTML and copy myfile.js from your plugin's folder to the exported directory. However, I would reiterate that using APIs asynchronously is better. Which API is it, out of curiosity?

  • Tutorial on the subject. Why try to make plugins ?

  • Kyatric, I think they were asking about automatically modifying it from a plugin rather than by hand.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley, i'ts Google Maps API.

    Thanks for your help.

  • Hey,

    I'm sincerely sorry to behave as a noob...

    That's true, I'm not a javascript coder but I really begin to understand it as well as the C2's SDK.

    Enough to do 5-6 functions in my "workinprogress" plugin in a short time of learning.

    I looked through the code of the facebook plugin. Read about asynchronous option for the Google Maps API.

    Nevertheless, I didn't figure out.

    Let me just explain you some things.

    I put this in a "googleapi.js" file

    function loadScript()


       var script = document.createElement("script");

       script.type = "text/javascript";

       script.src = "";



       window.onload = loadScript;

    I "dependency" it in my edittime.js

    It didn't work. I tried to put this function directly into instanceProto.onCreate = function() as well. But it didn't work too.

    Each time, I can see the link correctly added in the <head> of my html test in FireBug.

    But google is always not defined.

    The API is correctly called only when I put the link manually into the index.html after I exported it.

    Thanks for your help. I'm really grateful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)