The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PRO LEVEL: YT video performance.

Go down

In progress PRO LEVEL: YT video performance.

Post by Guest February 28th 2014, 9:24 pm

Hi there!

What I'm after is a restriction on a certain amount of posts in one forum only. I've set the level of posts per page to about 10, but still, when adding YT videos to one forum, loading pages is getting anyone near but getting a poor performance. Some hold 10 YT vids, some just only 1 or 2. So, what I'm persuing here is a way to restrict the amount of posts or limit the amount of YT videos per page loading per forum  so performance loading pages isn't compremised. This is very important to me to keep standards high on my pages! PLEASE HELP ME OUT!

Regards,

Samantha.
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur February 28th 2014, 10:47 pm

Hello SamanthaS,

If you wanted to do something with the embedded videos, you could try removing them and replacing them with their links. This would let the user decide if the wanted to watch the video or not; reducing the strain on the page, somewhat. An example could be this quick scratch :
Code:
$(document).ready(function() {
    $('.post .content embed').each(function() {
       var src = $(this).attr('src');
       $(this).before('<a href="'+src+'" target="_blank" id="yt_video">'+src+'</a>').remove();
    });
    $(document).on('click','#yt_video',function() {
       $('body').append('<div id="yt_filter" style="position:fixed;top:0px;left:0px;right:0px;bottom:0px;background:rgba(0,0,0, 0.5);cursor:pointer;z-index:10;"></div><div id="videoContent" style="position:fixed;top:100px;left:100px;right:100px;bottom:100px;z-index:12;"><embed allowfullscreen="true" allowscriptaccess="always" scale="exactfit" quality="high" wmode="transparent" type="application/x-shockwave-flash" src="'+$(this).attr('href')+'" pluginspage="http://www.macromedia.com/go/getflashplayer" style="width:100%;height:100%;"></div>');
       $('#yt_filter').click(function() {
          var stop = confirm('Do you wish to stop watching the video ?');
          if (stop == true) { $('#yt_filter, #videoContent').remove(); }
          else { return; }
       });
          return false;
   });
});

It grabs the embedded video URL and places it before it, it then removes the embedded video. After this, clicking the URL will open the video in a popup for viewing. I found anywhere around 5 embedded videos on a pages starts to get laggy. mwii
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Guest February 28th 2014, 10:51 pm

Yea, thanks Ange, and I should really friend u up some day again (EDIT: SENT YOU A REQUEST). I'm sorry bout the last time. I really should have know better.

I know it's getting laggy around 5 or more posted, but then again, it depends on the ammount of posts per page holding so many vids. I really don't know how to sum it all up here, but it looks like there's a real glitch to the ammount of vids posted before things start to get nasty (performance), not their size. So, if we could control that, we'd be fine, don't you agree? And again, in that forum only! So, X vids per page like?

Samantha.

EDIT: This can wait if you want. I'm in no real hurry here. It's getting late here, so I must go in a min, if you don't mind, but I really want to sort this sooner or later. Thanks for understanding!
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur February 28th 2014, 11:08 pm

If you wanted you could limit the amount of videos embedded on the page. After a specified limit, the embedded elements after that limit will be converted to a link.

Example :
* tick in the topics
Code:
$(document).ready(function() {
    
    var videos = '4'; /* videos converted to URL after 5 videos. 4 = 5, 0 = 1 */
    
    $('.post .content embed:gt('+videos+')').each(function() {
       var src = $(this).attr('src');
       $(this).before('<a href="'+src+'" target="_blank">'+src+'</a>').remove();
    });
});

our variable 'videos' contains a string with the number '4'. 4 is equal to 5 in this case. So after 5 videos, the rest after that on the current page are converted to links.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Guest February 28th 2014, 11:11 pm

So 5 is 6 and so forth? So I could limit them by 9 to get some performance still. Oh that's so cool! Good thinking! I'll test it in the morning again! Thanks for your help so far, Ange! Really appreciate it! Smile

Regards,

Samantha.

PS: If someone deletes a vid or a post, it'll recalculate it, so the links would be transformed into actual vids again?
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur February 28th 2014, 11:18 pm

de no problem.

Correct, 7=8, 9=10, and so on. Should someone delete a video, upon refreshing, the index number should change and the next video after your specified number will be a link. So most likely, a video you hadn't seen embedded would display as embedded.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Guest February 28th 2014, 11:20 pm

That's very cool stuff and clever thinking, Ange! You're very smart, like me Very Happy  ! Thing is, I don't know JS that well! Smile  Thank you!
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur March 1st 2014, 12:46 am

Thanks and you're welcome. I know jQuery well, but I'm not too great with vanilla JavaScript. I've been studying it and practicing though.

Has this been solved ?
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Guest March 4th 2014, 7:17 pm

Hi, I can work on it for like 15 minutes today, I'm sorry. I'll check on it right away Very Happy

Edit: Well seemed like my board was totally confused at first, which was pretty cool to watch at first sight... Like "WTH??? Another gimmo from good ol' Ange? OHNOOOOOO" Smile  Well, now it settled all down, I can see links pretty much all over the place, except for the 5 released and approved: http://www.game-xtreme.com/t18-music-topic so that's cool. So now your magic showed up pretty much all the place, which is kinda uncool.  I wanted this in 1 or selected few forum(s) only. So how do I go from here, now? I want this to get done in a couple of selected forums only!
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur March 4th 2014, 7:38 pm

Hmm..well, in that case you might have to go by the location, perhaps the topic ID. For example :
Code:
$(document).ready(function() {
    
    var videos = '4'; /* videos converted to URL after 5 videos. 4 = 5, 0 = 1 */
    
    if (document.location.href.indexOf('/t18-') > -1) {
       $('.post .content embed:gt('+videos+')').each(function() {
          var src = $(this).attr('src');
          $(this).before('<a href="'+src+'" target="_blank">'+src+'</a>').remove();
       });
    }
})

I'll have to see if I can figure something out for a specific forum since it doesn't show in the location.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Guest March 4th 2014, 7:43 pm

I understand, Ange. Take your time, please! I'm in no hurry here at all, yk, I just like to see it sorted, that's all! You're doing fine, I know!

Hey I'm not on during weekdays usually, so, IF you got a solution please respect a couple of hours or days for me to respond, ok? I'll be checking things out lateron, and that's for sure! I promise! You know me!  Smile  I DO respect you're looking into this and come up with a really great idea sometime.

Furthermore, I really appreciate what you're doing. I know the script's gonna grow bigger soon, as well as I stated it's "PRO LEVEL" Wink. You're doing fine, Ange! I hope you'll have fun solving this one, cuz I really can not!  Crying or Very sad  And that's why I opened up a support ticket on here.

Thanks for understanding, Ange! And good luck! Hope you'll find that golden key! Smile

PS: Darn, the smilies don't work, but that's just an extra to the way you already know how I feel about it. Oh, darny darn how I wish I could make'm smile Smile

EDIT: I always edit my posts cuz I don't like'm at first, so please take a deep (5 minute) breath before responding! AHAH! Wink
avatar
Guest
Guest


Back to top Go down

In progress Re: PRO LEVEL: YT video performance.

Post by Ange Tuteur March 5th 2014, 1:15 am

Okay try this :

* tick in the topics
Code:
$(document).ready(function() {
    
    var videos = '4'; /* videos converted to URL after 5 videos. 4 = 5, 0 = 1 */
    
    var URL = $('.topic-actions .nav:last').attr('href').replace(/-.*/,'').replace(/\/f/,'');
    var F = Number(URL);
    
    // the statement below is the IDs of a forum
    // add the forum ID you wish the script to run in
    if (F == 2 || F == 4 || F == 5) {  
      $('.post .content embed:gt('+videos+')').each(function() {
          var src = $(this).attr('src');
          $(this).before('<a href="'+src+'" target="_blank">'+src+'</a>').remove();
       });
    }
});

Using the nav links I could check the forum ID. We'll use this ID to choose what forums we want to convert the videos to an URL. You'll add the forums in the if statement :
Code:
if (F == 2 || F == 4 || F == 5)

F contains a number.
If F contains 2 and it is equal to 2(F == 2) then the function in the statement will run. You can check the forum ID from your address bar (/f25-). You should spearate multiple conditions like so :
Code:
F == 2 || F == 13 || F == 32 || F == 1
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum