Click here to Skip to main content
15,915,851 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using jquery to show video on website. I have perfomance speed issue for append() How can I improve the perfomance? Any comment would be appreciated Thanks

function viewvideo(videoid) {
//set vidoe in play-video page
varVideoid = videoid;
$("#video").empty();

var data = Ajax("../Ajax/Webmethod.aspx/getviewvideo", { videoid: videoid });
var str = '';


if (data.videourl.indexOf('youtube') == -1 && data.videourl.indexOf('youtu.be') == -1) {
    str += '<video id="myvideo" width="420" height="300"  autoplay="autoplay" ">';
    str += '<source src="' + data.videourl + '" type="video/mp4">';
    str += '<source src="' + data.videourl + '" type="video/3gpp">';
    str += '<source src="' + data.videourl + '" type="video/m4v">';
    str += '<source src="' + data.videourl + '" type="video/x-ms-wmv">';
    str += '<source src="' + data.videourl + '" type="video/webm">';
    str += '<source src="' + data.videourl + '" type="video/quicktime">';
    str += '<source src="' + data.videourl + '" type="video/ogg">';
    str += '<source src="' + data.videourl + '" type="video/mpeg">';
    str += '<source src="' + data.videourl + '" type="video/x-matroska">';
    str += '</video>';
}
else 
{

    str = data.videourl.replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g, '<iframe width="420" height="300" src="http://www.youtube.com/embed/$1?autoplay=1&modestbranding=1&autohide=0&showinfo=1" frameborder="0" allowfullscreen></iframe>');}
$("#video").append(str);
.
.
.
}


What I have tried:

I have commented
$("#video").append(str);
part then the speed is faster
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900