Needs review
Project:
Kaltura
Version:
6.x-1.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 May 2009 at 23:47 UTC
Updated:
16 Aug 2010 at 21:57 UTC
Jump to comment: Most recent file
I couldn't figure out why the player wouldn't work for me, then remembered that I changed where the javascript loads in my pages (to get a better YSlow score dontchaknow). When I moved the Drupal javascript calls back to the header in the template, the player appeared.
Kaltura adds a lot of javascript to page loads. I don't mind having the js load after the content, but if it breaks the player, it will be a problem under load.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | kaltura_455810.patch | 4.21 KB | dsayswhat |
Comments
Comment #1
Zohar.Babin commentedthe player is loaded using SWFObject and based on jquery (drupal's core jquery, or jquery update module).
if the loading sequnce was changed, perhaps the jquery functions were not yet available at the time where other kaltura JS functions expected it to be available.
I'm not quite sure why changing the load sequence of the JS files had any affect on YSlow score...
I do know that using JS aggregation feature enables you to have one big JS file so it reduces the number of files loaded in the page and thus affects YSlow score.
I suggest you try using js aggregation for load issue, since I don't see a way where Kaltura's JS could be loaded in a different sequence.
Comment #2
dsayswhat commentedLoading scripts last has become a pretty standard best practice - Yslow and similar optimization tools by the performance experts have been recommended putting script calls at the end of html files for several years now.
See http://developer.yahoo.com/performance/rules.html - look for 'put scripts at the bottom' the short version is that is halts loading of other page elements, so loading markup and css gives the user something to look at while the scripts come in - otherwise the page loads at the mercy of the scripts, and users have to wait.
The real issue for Kaltura is that you're making the success of your module dependant on the choices of themers - who should be free to put the scripts in any order they want, when you really get down to it. Your stuff appears broken when we go about things the way we're 'supposed to'.
I'll take a look and see if I can make a patch...at the least, I'll respond with where I think you might optimize...
Comment #3
dsayswhat commentedUpon review of the Kaltura module, there's multiple spots where the javascript could be refactored.
From a maintainability standpoint, it's easier to work with Kaltura's JS code if it's implemented using http://api.drupal.org/api/function/drupal_add_js/6, instead of built from string concatenations as it currently is done in kaltura_themeing.inc.
I've attached a patchfile that pulls the player javascript rendering out of the kaltura_themeing.inc file and externalizes it - using Drupal.settings and Drupal.behaviors as described here: http://drupal.org/node/205296. It's the prescribed way that Drupal does JS, and avoids the load order problem described in this issue. Themes that add scripts at the end will play more nicely with Kaltura.
There are several other script tags embedded in the includes/kaltura_themeing.inc file which I haven't bothered to patch, as I'm wary of getting too deep into code that I don't know. It could all do with refactoring, though.
The change I made was pretty straightforward, but might run into complications with multiple players on a page - I'll leave it to you to identify a solution for that use case, as you're better equipped to know which end is up on this stuff.