Jump to content

kt player


Maciej

Recommended Posts

I have another problem,

 

I would like to add ktplayer js code <script type="1cffa31abd315d8a0900537f-text/javascript" src="https://domain.com/player/kt_player.js?v=5.1.1"></script> in header off my website with preload mode.

 

<link rel="preload" href="https://domain.com/player/kt_player.js?v=5.1.1" as="script">

 

for faster load player but it not working when i use preload mode.

 

more info here: https://web.dev/preload-critical-assets/

 

Link to comment
Share on other sites

It doesn't make any sense to preload player JS, because it is loaded right in the place where it is being used.

The preload only makes sense for font resources due to this issue:

  1. Browser loads CSS stylesheet
  2. Your CSS stylesheet refers external resources such as web fonts
  3. Browsers applies CSS stylesheet without web font
  4. Browser loads web font
  5. Browser applies the loaded web font

So here in this chain of events there is a short delay between 3 and 5, which is 4 to load external font resource. During this delay your site may be using default (fallback) font for a fraction of seconds, but this may be visible to the end user like site is blinking for a while, especially for users with slow internet connection. I'm sure you saw this many times on different sites, when first default font is loaded and then site will be a bit re-positioned with the final font, which may result in elements rendered with other sizes due to font metrics differences. This causes blinking effect.

Therefore you can use preloading technique to preload font resource before including CSS stylesheet that will use it. In this case event #4 will be moved before event #1, e.g. you first preload web font and then browser will load CSS stylesheet and there will be no delay #4 in rendering. But even this doesn't make the whole page load faster. The loading time is the same, because the same set of resources is needed to render the page, they are just loaded in the different order.

With regard to player there is no difference when player file is preloaded - either in the beginning of the page, or in the middle of the page (where it is set now), because it is used in the middle of the page right after it is being loaded. Moving player JS file to preload sequence will not make player appear faster.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...