Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 12:50 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PreLoading External JS libraries
PostPosted: October 14th, 2017, 5:31 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Seems that Opus HTML5 pubs may load some external JS libraries slowly (or not at all) especially if these are large libraries. Not sure if this is the amount of memory used to load a large resource or a conflict with loading the Opus.js (or both)?

Would (1) pre-loading external JS libraries or (2) another work-around/method that "deconflicts" the Opus JS and an external JS library improve this?

External JS libraries that can be successfully and reasonably quickly loaded would be a great benefit to producing a wider range of Opus HTML 5 and Android pubs.

Any thoughts, suggestions appreciated.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: PreLoading External JS libraries
PostPosted: October 16th, 2017, 5:11 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
My thought is that Opus HTML5 is just that - HTML5 so adding a <script> tag with a src for an external library is no different to adding the same script tag to HTML5 developed in Dreamweaver or Atom or Brackets. The loading time will be the same. You can check this in the network tab of your debug tools.

There are issues that affect loading and executing and if you want to induce brain ache you can read about them here: https://www.html5rocks.com/en/tutorials ... t-loading/

I question however what you are trying to achieve. Your application is built in Opus, therefore your primary JavaScript library is Opus.js. Unless, you are trying to mess with what happens to the code that Opus has generated (in which case you deserve brain ache), you should be able to load your script after Opus has finished and execute it's functions when necessary.

For example, in my Canvas project. nothing in the external script loads until the function is called so it's all controlled from my Opus project. Secondly, my script tag uses the defer attribute:

Code:
<script src=canvas.js defer> </script>


This loads the script after the page has parsed. Technically, it's not necessary. Nothing in my script interferes with the loading of page but as I don't need it immediately. it seems unlikely that the user will reach the page that loads the function from the script before it is ready. It this was going to happen, I would not have used defer, but I would still only have functions for the script execute when the page was up and running.

On this point, if you absolutely must have the functions in your external library available immediately, then you simply need to add the script tag in the head box of the setting without attributes such as defer. This will download and execute the script before the document is parsed. However, if the JS library is large, then the speed of your internet connection will have an impact on loading the page as seen in the browser - but if the script also executes something, this has to complete first - all of which adds to a delay before you get a page to the user.

If you want the script to download and run but not block the page, you can try the async attribute but be warned that it better not interfere with anything that is happening with the page as it's like to throw errors.

I'll repeat what I said earlier, that personally, unless necessary, it is best to download scripts that do not run any functions until they are called by something in your Opus project. Allow the Opus bits of code to parse and execute first.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: PreLoading External JS libraries
PostPosted: October 16th, 2017, 6:36 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Mack,

Thank you for these thoughts and suggestions. Very helpful.

I too had found the defer tag, experimented with it. Your suggestions refine if/when best to use it.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group