HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Testing Video load

422422 Developer MVP

I just want to test video loading via Youtube.

I am noticing severe lag on our forum, and so wanted to see what could be done to fix the issue.

Here is a video from youtube. On page load, I want to see resources and issues, regarding load time etc.

https://www.youtube.com/watch?v=W3OQgh_h4U4

Ultimately, I want to know where the js is that controls the loading of the video.

Essentially, want to see if the script for loading the youtube video loads asynchronously on here.

var script = document.createElement('script'),
    scripts = document.getElementsByTagName('script')[0];
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);

There was an error rendering this rich post.

Comments

  • Options
    422422 Developer MVP

    Ok so in 2.0.18.4 where is the js for handling youtube vids.

    I note in 2.1 ( used on here that video is loaded onclick not onload )

    So wondering if its possible to upgrade the js used on my forum, to something similar to the vanillaforums, as the performance gain is huge

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP

    Enclosed two screenshots of how my version differs from new vanilla version.

    Must admit I am impressed. So is there a workaround for this on versions other than 2.1 ?

    I am wondering what @peregrine thinks. ? ( would post @kasper and @vrij ) but your names are so hard to bloody remember. Be great if after the @ symbol the username autocompletes !

    Anyhoo thats for another time, any suggestions on bringing youtube loading on 2.0 versions of vanilla kicking and screaming into the 21st century akin to the 2.1 versions.

    There was an error rendering this rich post.

  • Options
    businessdadbusinessdad Stealth contributor MVP
    edited March 2013

    Here you go (I think), from global.js:

    // Reveal youtube player when preview clicked.
       function Youtube(Container) {
          var $preview = Container.find('.VideoPreview');
          var $player = Container.find('.VideoPlayer');
          var width = $preview.width(), height = $preview.height(), videoid = Container.attr('id').replace('youtube-', '');
    
          $preview.hide();
          $player.html('<object width="'+width+'" height="'+height+'">'
             + '<param name="movie" value="http://www.youtube.com/v/'+videoid+'&amp;hl=en_US&amp;fs=1&amp;autoplay=1"></param>'
             + '<param name="allowFullScreen" value="true"></param>'
             + '<param name="allowscriptaccess" value="always"></param>'
             + '<embed src="http://www.youtube.com/v/'+videoid+'&amp;hl=en_US&amp;fs=1&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+width+'" height="'+height+'"></embed>'
             + '</object>');
          $player.show();
    
          return false;
       }
    
       $(document).delegate('.Video.YouTube .VideoPreview', 'click', function(e) {
          var $target = $(e.target);
          var $container = $target.closest('.Video.YouTube');
          return Youtube($container);
       });
    
  • Options
    422422 Developer MVP

    Cheers that looks great but , what js file currently handles the youtube code ( js ) in vanilla 2.0.18.4
    Obiously would want to replace current handling js with this to test.

    Its not in global that i can see lol... so where is it grrrr ;)

    There was an error rendering this rich post.

  • Options

    ey @422 the lag from youtube in forums not is for "youtube" or forums. Is a oficial "bug" by Flash Player. The last 4 updates is for try to fix this problems.

    So much forums with embed videos from youtube have this problem. For example every day i visit one forum in PhpBB3 with so muchs videos from youtube, vimeo, ect... And always have frozen problems and need closed firefox.

    I can try to explain u more, but not in english :(

  • Options
    businessdadbusinessdad Stealth contributor MVP

    @422 said:
    Cheers that looks great but , what js file currently handles the youtube code ( js ) in vanilla 2.0.18.4
    Obiously would want to replace current handling js with this to test.

    Its not in global that i can see lol... so where is it grrrr ;)

    Sorry, I misunderstood. If you give me the URL of the forum, I can have a look for you (I don't have handy a Vanilla 2.0 with videos enabled).

  • Options
    422422 Developer MVP

    No

    Thanks for your input but you are missing the point, please study the images I posted in the posts above.
    To allay the issue of lag, irrespective of flash / html5 etc, vanilla 2.1 actually fetches the image of the video, and displays that. Then onclick fetches the video.

    This massively reduces lag on page.

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP
    edited March 2013

    Unfortunatley its behind closed doors. But will load a video up on one of our other forums, and pass you the url mate.

    Test here: http://vanillaskins.com/response/discussion/34/posting-a-youtube-video

    There was an error rendering this rich post.

  • Options
    businessdadbusinessdad Stealth contributor MVP
    edited March 2013

    @422 said:
    Unfortunatley its behind closed doors. But will load a video up on one of our other forums, and pass you the url mate.
    Test here: http://vanillaskins.com/response/discussion/34/posting-a-youtube-video

    I see now. I think that you can't find the script, because there isn't one. In the above page, the video is embedded directly, as a flash object, while in this thread, there is only an image, which is replaced by the video once you click on it.

    I would suggest to look for the PHP code that renders the page and see if you can port it.

    Edit
    To be more precise, here's how the video is rendered:

    • A preview image, with the same size of the video, is put on the page, instead of the video flash object.
    • The image is contained in a <div> with the class VideoPreview, which shows the YouTube play button.
    • Clicking on the button (i.e. on the <div>), triggers the script, which replaces the image with the flash object and plays the video.
  • Options
    422422 Developer MVP
    edited March 2013

    Yeah gonna give that a bash,

    reason being on our master forum, its firing 333 page requests the majority to youtube !

    On that one ( linked above ) 44 page requests total and i think 3 to youtube

    On master forum, with no youtube vid, 98 requests.

    On this thread here 57 requests

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP
    edited March 2013

    Just realised the forum with the issue is running 2.0.18.1 > time to bloody upgrade

    Ok now to find posts and threads related to upgrades.

    There was an error rendering this rich post.

Sign In or Register to comment.